<template>
	<div class="home" @click="goodSearchList=[]">
		<!-- <div class="top">
			<span class="left storeName" v-text="'欢迎光临 '+storeInfo.name"></span>
			<span class="left personName" v-text="'您当前的座位号为 No.'"></span>
			<span class="left tableNo" v-text="decodeURI(tableNo)"></span>
			<div class="right search clearfix">
				<input type="text" class="left keywords" v-model="goodSearch" placeholder="请输入关键词">
				<i class="left iconfont icon-magnifier"></i>
				<ul class="goodCheckList" :style="{display:(goodSearchList[0]?'block':'none')}" @click.stop="">
				    <li v-for="(item,index) in goodSearchList" @click="selSearchGood(item.id)" :key="index">
				        <div class="left name" v-text="item.name" :title="item.name"></div>
				    </li>
				</ul>
			</div>
			<div class="right car" @click="choiceArr.length<=0?'':showCarDetail=true">我的购物车<span v-text="goodLength"></span><i class="iconfont icon-gouwuche"></i></div>
			<div class="right vipInfoBox" v-if="personData">
				<div class="title">会员信息</div>
				<div class="vipInfo">
					<div class="infoItem"><span>会员名：</span><span class="name" v-text="personData.name"></span></div>
					<div class="infoItem"><span>会员号：</span><span v-text="personData.mobile?personData.mobile:personData.code"></span></div>
					<div class="infoItem"><span>积分：</span><span v-text="personData.memberAccount.points"></span></div>
					<div class="infoItem totalAmount"><span>余额：</span><span class="money" v-text="'￥'+personData.memberAccount.totalAmount"></span></div>
					<div class="btnGroup">
						<button type="button" @click="loginOut">退出登录</button>
					</div>
				</div>
			</div>
		</div> -->
		<div class="goodBox clearfix">
			<div class="leftBar left">
				<div class="store-info">
					<div class="logo">
						<img :src="storeInfo.storeLogo+'?x-oss-process=image/resize,l_300'" alt="">
					</div>
					<div class="store-name">
						<p>欢迎光临</p>
						<p class="name">{{storeInfo.name}}</p>
					</div>
				</div>
				<div class="menu-list">
					<ul v-if="goodsData[0]">
						<li v-for="(item, idx) in goodsData" :class="{active:(curTypeIdx==idx)}" v-if="item.dontShowThisCate && item.isShow">
							<div class="bigType" v-text="item.typeName" :title="item.typeName" @click="selGoodType(idx)"></div>
							<div :class="curTypeIdx==idx&&curSmallTypeIdx>=0&&smallIdx==curSmallTypeIdx?'smallType active':'smallType'" 
								v-for="(oitem,smallIdx) in item.subTypes" 
								:title="oitem.typeName" v-text="oitem.typeName" 
								v-if="oitem.isShow"
								@click="selSmallGoodType(idx,smallIdx)"></div>
							<!-- <i v-if="curTypeIdx==idx&&curSmallTypeIdx>=0" class="iconfont icon-jiantou1" :style="{top:(65+curSmallTypeIdx*36)+'px'}"></i> -->
						</li>
					</ul>
				</div>
			</div>
			<div class="right-cont">
				<div class="top-info">
					<span>欢迎光临 {{storeInfo.name}} 您当前的座位号是：{{decodeURI(tableNo)}}</span>
					<div class="search-wrap" ref="searchWrap" style="display:flex;align-items:center;">
						<span class="myRentBtn" @click.stop="doShowMyRentInfo" v-if="myRentData && Array.isArray(myRentData) && myRentData.length">
							<svg t="1732779673053" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6106" width="28" height="28"><path d="M541.5 564.3h143.1V453.8H541.5v110.5z m0-145.4h143.1V315.3H541.5v103.6z m0 295.4h143.1v-115H541.5v115zM512 47C255.2 47 47 255.2 47 512s208.2 465 465 465 465-208.2 465-465S768.8 47 512 47zM389.3 767.6h-36V507.1c-23.5 59.5-53.8 119.1-83 155.1-4.6-10.3-13.7-25.2-20-33.8 35.5-41.8 75.5-117.9 97.9-185.5h-91v-35.5h96.1v-89.3c-26.3 5.1-53.2 9.2-78.4 12.6-1.7-8-6.9-21.2-10.9-29.8 63.5-9.7 139.1-26.9 181.4-45.2l24 29.8c-22.3 9.2-50.4 17.2-80.1 24.6v97.3H470V443h-80.7v10.3c16 18.3 68.7 86.4 80.1 102.5L446 585.5c-10.3-19.5-36.6-60.7-56.6-89.9v272z m388-17.8H445.4v-35.5h59V279.8h219.1v434.5h53.8v35.5z" fill="#EE373F" p-id="6107"></path></svg>
							<b>我的租赁</b>
						</span>
						<el-input v-model="keywords" size="small" placeholder="请输入商品名称进行搜索"/>
						<!-- <el-autocomplete
							v-model="keywords"
							size="small"
							:popper-append-to-body="true"
							:fetch-suggestions="querySearchAsync"
							placeholder="请输入商品名称进行搜索"
							style="width:100%;"
							>
							<i class="el-icon-search" slot="suffix"></i>
							<template slot-scope="{ item }">
								<div class="name" @click.stop="beforeSelSearchGoods($event,item)">{{ item.name }}</div>
							</template>
						</el-autocomplete> -->
					</div>
				</div>
				<div class="goodListBox left">
					<div class="scroll" id="scroller">
						<div class="goodList clearfix">
							<div v-for="(item, idx) in curSelGoodsData.products" v-if="item.showEnabled" :key="idx" class="goodItem left" :class="{'nowNotSupply':doShowSupply(item.supplyTimes)}">
								<div class="goods-inner-wrap">
									<div class="goods-img" :ref="item.id" @click.stop="item.purchaseEnabled?beforeSelGoodsWithImg(item):''">
										<el-image :src="imgStaticUrl + item.imageURl+'?x-oss-process=image/resize,l_300'" alt="" lazy class="img"/>
										<!-- <div class="info">
											<div class="goods-price">
												<span class="val">￥ {{item.salesPrice}}</span>
												<div class="line">
													<span></span>
												</div>
											</div>
											<div class="goods-name">
												<div class="line">
													<span></span>
												</div>
												<span class="val">{{item.name}}</span>
												<span class="val note" v-if="item.note!=null">{{item.note}}</span>
											</div>
											<div class="info-mask"></div>
										</div> -->
									</div>
									<!-- <div class="name" v-text="item.name" :title="item.name"></div>
									<div class="price" :style="!item.purchaseEnabled?'width:100%;padding:0;':''" v-text="'￥'+item.salesPrice"></div> -->
									<div class="addBtn new">
										<!--  -->
										<div class="gprice" v-if="!item.leaseEnabled"><span>￥</span>{{item.salesPrice}}</div>
										<div class="gprice" style="font-size:16px" v-else>{{ item.name }}</div>
										<div class="gnote" v-if="item.note!=null" :title="item.note">{{item.note}}</div>
										<div class="gname" v-if="!item.leaseEnabled" :class="{hasNote:item.note}" :title="item.name">{{item.name}}</div>
										<div class="gname" v-else :class="{hasNote:item.note}" :title="item.name">余量:{{item.quantity}}</div>
										<!--  -->
										<template v-if="!item.leaseEnabled">
											<button type="button" v-if="item.purchaseEnabled"
											@click.stop="beforeSelGoods($event,item)">
											<i class="iconfont icon-gouwuche"><span v-if="item.nowSelectCount>0" class="now-select-count">{{item.nowSelectCount}}</span></i>
											<span class="add-cart" v-if="(item.stockEnabled&&!item.quantity)">无货</span>
											<span class="add-cart" v-else>加入购物车</span>
											</button>
											<button type="button" style="color:#999;" v-if="!item.purchaseEnabled"
											@click.stop="">
											<span class="add-cart">请呼叫购买</span>
											</button>
										</template>
										<template v-else>
											<button type="button" @click.stop="beforeSelGoods($event,item)">
												<i class="iconfont icon-gouwuche"></i>
												<span class="add-cart">租赁此商品</span>
											</button>
										</template>
									</div>
								</div>
							</div>
						</div>
						<div class="goodList clearfix" v-for="(item, idx) in curSelGoodsData.subTypes" :key="idx">
							<div class="title" v-text="item.typeName"></div>
							<div v-for="(item, idx) in item.products" class="goodItem left" v-if="item.showEnabled" :class="{'nowNotSupply':doShowSupply(item.supplyTimes)}">
								<div class="goods-inner-wrap">
								<!-- <img :data-echo="item.imageURl+'?x-oss-process=image/resize,l_300'" alt="" class="img">
								<div class="name" v-text="item.name"></div>
								<div class="price" :style="!item.purchaseEnabled?'width:100%;padding:0;':''" v-text="'￥'+item.salesPrice"></div>
								<div class="addBtn">
									<button type="button" v-if="item.purchaseEnabled"
									@click.stop="addProduct( $event, item.id,false );changeNowSelectCount(item,false,'add',doShowSupply(item.supplyTimes));">
									<i class="iconfont icon-gouwuche"><span v-if="item.nowSelectCount>0" class="now-select-count">{{item.nowSelectCount}}</span></i>
									<span class="add-cart">加入购物车</span>
									</button>
								</div> -->
									<div class="goods-img" :ref="item.id" @click.stop="item.purchaseEnabled?beforeSelGoodsWithImg(item):''">
										<el-image :src="imgStaticUrl + item.imageURl+'?x-oss-process=image/resize,l_300'" lazy alt="" class="img"/>
										<!-- <div class="info">
											<div class="goods-price">
												<span class="val">￥ {{item.salesPrice}}</span>
												<div class="line">
													<span></span>
												</div>
											</div>
											<div class="goods-name">
												<div class="line">
													<span></span>
												</div>
												<span class="val">{{item.name}}</span>
												<span class="val note" v-if="item.note!=null">{{item.note}}</span>
											</div>
											<div class="info-mask"></div>
										</div> -->
									</div>
									<div class="addBtn new">
										<!--  -->
										<div class="gprice"><span>￥</span>{{item.salesPrice}}</div>
										<div class="gnote" v-if="item.note!=null" :title="item.note">{{item.note}}</div>
										<div class="gname" :class="{hasNote:item.note}" :title="item.name">{{item.name}}</div>
										<!--  -->
										<button type="button" v-if="item.purchaseEnabled"
										@click.stop="beforeSelGoods($event,item)">
										<i class="iconfont icon-gouwuche"><span v-if="item.nowSelectCount>0" class="now-select-count">{{item.nowSelectCount}}</span></i>
										<!-- <span class="add-cart" v-if="(item.stockEnabled&&item.quantity) || !item.stockEnabled">加入购物车</span> -->
										<span class="add-cart" v-if="(item.stockEnabled&&!item.quantity)">无货</span>
										<span class="add-cart" v-else>加入购物车</span>
										</button>
										<button type="button" style="color:#999;" v-if="!item.purchaseEnabled"
										@click.stop="">
										<span class="add-cart">请呼叫购买</span>
										</button>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="right-cart">
				<i class="iconfont icon-gouwuche1" @click="choiceArr.length<=0?'':showCarDetail=true">
					<b class="goods-count" v-if="goodLength>0">{{goodLength}}</b>
				</i>
				<i class="iconfont icon-solid-person">
					<div class="vipInfoBox" v-if="personData">
						<div class="title">会员信息</div>
						<div class="vipInfo">
							<div class="infoItem"><span>会员名：</span><span class="name" v-text="personData.name">{</span></div>
							<div class="infoItem"><span>会员号：</span><span v-text="personData.mobile?personData.mobile:personData.code"></span></div>
							<div class="infoItem"><span>积分：</span><span v-text="personData.memberAccount.points"></span></div>
							<div class="infoItem totalAmount"><span>余额：</span><span class="money" v-text="'￥'+personData.memberAccount.totalAmount"></span></div>
							<div class="btnGroup">
								<button type="button" @click="loginOut">退出登录</button>
							</div>
						</div>
					</div>
				</i>
			</div>
			<div class="animateBox" id="animateBox">
				<img src="../../assets/bird.gif" height="110" width="110" alt="">
			</div>
		</div>
		<div class="carMask mask" v-if="showCarDetail" @click="showCarDetail=false">
			<div class="carBox box position-middle-center" @click.stop="">
				<div class="title">购物车<span class="closeBtn" @click="showCarDetail=false">&times;</span></div>
				<div class="tableTitle clearfix">
					<div class="left" style="width:40%">商品名称</div>
					<div class="left" style="width:20%">价格</div>
					<div class="left" style="width:30%">数量</div>
					<div class="left" style="width:10%">小计</div>
				</div>
				<div class="scroll">
					<ul class="goodList">
						<li v-for="(item,idx) in choiceArr" class="clearfix">
							<div style="width:40%" class="img name-wrap">
								<img :src="imgStaticUrl + item.productImageURL+'?x-oss-process=image/resize,l_300'" alt="">
								<div class="name">
									{{item.productName}}
									<!-- 规格start -->
									<div class="spec-info" v-if="item.specs && Array.isArray(item.specs) && item.specs.length">
										规格：<span class="tag" v-for="(it,ind) in item.specs" :key="ind">{{it}}</span>
									</div>
									<!-- 规格end -->
									<div class="add-pei" v-if="item.matchEnabled">
										<button @click="doShowPeiGoods(item)">添加配品</button>
									</div>
								</div>
							</div>
							<div style="width:20%" class="price" v-text="'￥'+(item.salesPrice/item.quantity).toFixed(2)"></div>
							<div style="width:30%" class="quantity">
								<button class="reduce" @click="reduceProduct(item, item.productId );changeNowSelectCount(item,false,'reduce')">-</button>
								<span class="number" v-text="item.quantity"></span>
								<button class="add" @click="beforeAddCount($event,item)">+</button>
								<!-- <button class="del" @click="reduceProduct(item,item.productId, item.quantity);changeNowSelectCount(item,false,'del')">X</button> -->
							</div>
							<div style="width:10%" class="cost" v-text="'￥'+item.salesPrice.toFixed(2)"></div>
							<div class="sub-items" v-if="item.masterItemDtos && Array.isArray(item.masterItemDtos) && item.masterItemDtos.length">
								<li v-for="(it,ind) in item.masterItemDtos" class="clearfix">
									<div style="width:40%" class="img name-wrap">
										<div class="name">
											<i class="pei">配</i>{{it.productName}}
										</div>
									</div>
									<div style="width:20%" class="price" v-text="'￥'+(it.salesPrice/it.quantity).toFixed(2)"></div>
									<div style="width:30%" class="quantity clearfix">
										<button class="reduce" @click="reduceAmountForPei(it);">-</button>
										<span class="number" v-text="it.quantity"></span>
										<button class="add" @click="addAmountForPei(item,it);">+</button>
									</div>
									<div style="width:10%" class="cost" v-text="'￥'+it.salesPrice.toFixed(2)"></div>
								</li>
							</div>
						</li>
					</ul>
				</div>

				<div class="total clearfix" v-if="curBindCoupon[0]" style="margin-bottom:10px;">
					<div class="left coupon" v-text="'当前已使用优惠券：  '+curBindCoupon[0].couponName"></div>
				</div>
				<!-- <div class="total clearfix topay" :class="{delivery:storeInfo.deliveryEnabled}"> -->
				<div class="total clearfix topay">
					<div class="left-cont">
						<div class=" coupon"> 备注：</div>
						<div class=" notes">
							<input type="text" placeholder="请输入口味、偏好等要求！（选填）" v-model="notes">
						</div>
					</div>
					<!-- <div class="sel-emp" v-if="storeInfo.deliveryEnabled">
						<div class="left coupon"> 配送员：</div>
						<el-select v-model="nowSelEmp" placeholder="请选择">
							<el-option
							v-for="item in emps"
							:key="item.id"
							:label="item.name"
							:value="item.id">
							</el-option>
						</el-select>
					</div> -->
					<!-- <span>撤销订单</span> -->
					<div class="right-cont">
						<div class="totalPrice " v-text="'总计：￥'+totalPrice.amount.toFixed(2)"></div>
						<button type="button" class="" v-if="storeInfo.deliveryEnabled" @click="doShowEmp">结算</button>
						<button type="button" class="" v-else @click="goBalance()">结算</button>
					</div>
				</div>
			</div>
		</div> 
		<!-- 结算 -->
		<!-- new pay -->
		<div class="balance-wrap" v-if="showBalance">
			<div class="inner-banlance-wrap">
				<div class="tit-wrap">
					<span class="tit">收银台</span>
					<span class="close" @click="closeBalance">&times;</span>
				</div>
				<div class="pay-info">
					<div class="item-info">
						<span class="item-tit">待付金额</span>
						<span class="amount">￥<span class="val">{{totalPrice.amount.toFixed(2)}}</span></span>
						<span class="discount" style="padding-left:10px" v-if="totalPrice.discount">
							<span class="item-tit">优惠金额:</span>
							<span class="amount" style="padding-left:5px">￥<span class="val" style="font-size:16px">{{totalPrice.discount.toFixed(2)}}</span></span>
						</span>
					</div>
				</div>
				<div class="vip" v-if="memberEnabled">
					<template v-if="!personData">
						<span class="tit">绑定优惠:</span>
						<span class="phone-inp">
							<input placeholder="手机号码" v-model="inpPhone"/>
							<span class="getcode" @click.stop="getCode">{{btnInfo}}</span>
						</span>
						<span class="tit">验证码:</span>
						<span class="code-inp">
							<input placeholder="验证码" v-model="phoneCode" class="code"/>
						</span>
						<span class="btn" @click.stop="memberLogin">绑定</span>
					</template>
					<template v-else>
						<span class="item">
							<span class="tit">会员名:</span>
							<span class="val" style="color:#fd8d20">{{personData.name}}</span>
						</span>
						<span class="item" style="padding-left:10px;">
							<span class="tit">余额:</span>
							<span class="val" style="color:#fd8d20">{{personData.memberAccount.totalAmount}}</span>
						</span>
						<span class="item" style="padding-left:10px;">
							<!-- <span class="tit">优惠券:</span> -->
							<span class="val" style="color:#fd8d20;cursor:pointer;" @click.stop="openCoupon">
								{{curBindCoupon[0]?curBindCoupon[0].couponName:'选择优惠券'}}<span class="reliveCoupon" @click.stop="relieveCoupon(curBindCoupon[0])" v-if="curBindCoupon[0]">x</span>
							</span>
						</span>
					</template>
				</div>
				<div class="pay-wrap">
					<div class="change-type">
						<span class="type online" :class="{active:nowSelPayType == 'online'}" @click.stop="changePayType('online')"><svg t="1684984394784" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2629" width="20" height="20"><path d="M798.848 512C817.216 512 832.064 497.728 832 480 832.064 462.336 817.216 448 798.848 448L576 448 576 429.248l246.016-246.016c12.992-12.992 13.376-33.6 0.896-46.08-12.352-12.544-33.152-12.096-46.144 0.832L544 370.688 311.232 137.984c-12.928-12.928-33.664-13.376-46.08-0.832-12.48 12.416-12.16 33.088 0.896 46.08L512 429.248 512 448 289.152 448C270.848 448 255.936 462.336 256 480 256 497.6 270.784 512 289.216 512L512 512l0 128L289.152 640C270.848 640 255.936 654.4 256 672 256 689.6 270.784 704 289.216 704L512 704l0 158.848C512 881.152 526.272 896 544 896 561.6 896 576 881.152 576 862.848L576 704l222.848 0c18.304 0 33.216-14.272 33.152-32 0.064-17.6-14.784-32-33.152-32L576 640 576 512 798.848 512z" fill="#0cb306" p-id="2630"></path></svg><span style="padding-left:5px">在线支付</span></span>
						<!-- <span class="line"></span> -->
						<!-- <span class="type last" :class="{active:nowSelPayType == 'last'}" @click.stop="changePayType('last')"><svg t="1684984394784" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2629" width="20" height="20"><path d="M798.848 512C817.216 512 832.064 497.728 832 480 832.064 462.336 817.216 448 798.848 448L576 448 576 429.248l246.016-246.016c12.992-12.992 13.376-33.6 0.896-46.08-12.352-12.544-33.152-12.096-46.144 0.832L544 370.688 311.232 137.984c-12.928-12.928-33.664-13.376-46.08-0.832-12.48 12.416-12.16 33.088 0.896 46.08L512 429.248 512 448 289.152 448C270.848 448 255.936 462.336 256 480 256 497.6 270.784 512 289.216 512L512 512l0 128L289.152 640C270.848 640 255.936 654.4 256 672 256 689.6 270.784 704 289.216 704L512 704l0 158.848C512 881.152 526.272 896 544 896 561.6 896 576 881.152 576 862.848L576 704l222.848 0c18.304 0 33.216-14.272 33.152-32 0.064-17.6-14.784-32-33.152-32L576 640 576 512 798.848 512z" fill="#0cb306" p-id="2630"></path></svg><span style="padding-left:5px">余额支付</span></span> -->
					</div>
					<div class="code-wrap" v-show="nowSelPayType=='online'&&!showSureOnlinePay">
						<div class="tit">
							<span>支持付款：</span>
							<svg t="1684984764690" class="pay-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4549" width="26" height="26"><path d="M352.814545 385.396364m-33.512727 0a33.512727 33.512727 0 1 0 67.025455 0 33.512727 33.512727 0 1 0-67.025455 0Z" fill="#50B674" p-id="4550"></path><path d="M502.690909 384.465455m-33.512727 0a33.512727 33.512727 0 1 0 67.025454 0 33.512727 33.512727 0 1 0-67.025454 0Z" fill="#50B674" p-id="4551"></path><path d="M576.232727 534.341818m-23.272727 0a23.272727 23.272727 0 1 0 46.545455 0 23.272727 23.272727 0 1 0-46.545455 0Z" fill="#50B674" p-id="4552"></path><path d="M694.458182 536.203636m-23.272727 0a23.272727 23.272727 0 1 0 46.545454 0 23.272727 23.272727 0 1 0-46.545454 0Z" fill="#50B674" p-id="4553"></path><path d="M512 0C229.003636 0 0 229.003636 0 512s229.003636 512 512 512 512-229.003636 512-512S794.996364 0 512 0z m-87.505455 630.225455c-26.996364 0-48.407273-5.585455-75.403636-11.17091l-75.403636 37.236364 21.410909-64.232727c-53.992727-37.236364-85.643636-85.643636-85.643637-145.221818 0-102.4 96.814545-182.458182 215.04-182.458182 105.192727 0 198.283636 64.232727 216.901819 150.807273-6.516364-0.930909-13.963636-0.930909-20.48-0.93091-102.4 0-182.458182 76.334545-182.458182 170.356364 0 15.825455 2.792727 30.72 6.516363 44.683636-7.447273 0-13.963636 0.930909-20.48 0.93091z m314.647273 75.403636l15.825455 53.992727-58.647273-32.581818c-21.410909 5.585455-42.821818 11.170909-64.232727 11.170909-102.4 0-182.458182-69.818182-182.458182-155.461818s80.058182-155.461818 182.458182-155.461818c96.814545 0 182.458182 69.818182 182.458182 155.461818 0 47.476364-31.650909 90.298182-75.403637 122.88z" fill="#50B674" p-id="4554"></path></svg>
							<svg t="1684984787818" class="pay-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6327" width="24" height="24"><path d="M860.16 0C950.272 0 1024 73.889684 1024 164.163368v531.509895s-32.768-4.122947-180.224-53.355789c-40.96-14.362947-96.256-34.896842-157.696-57.478737 36.864-63.595789 65.536-137.485474 86.016-215.444211h-202.752v-71.841684h247.808V256.512h-247.808V135.437474h-100.352c-18.432 0-18.432 18.458947-18.432 18.458947v104.663579H200.704v41.040842h249.856v69.793684H243.712v41.013895H645.12c-14.336 51.307789-34.816 98.519579-57.344 141.608421-129.024-43.115789-268.288-77.985684-356.352-55.403789-55.296 14.362947-92.16 38.992842-112.64 63.595789-96.256 116.978526-26.624 295.504842 176.128 295.504842 120.832 0 237.568-67.718737 327.68-178.526316C757.76 742.858105 1024 853.692632 1024 853.692632v6.144C1024 950.110316 950.272 1024 860.16 1024H163.84C73.728 1024 0 950.137263 0 859.836632V164.163368C0 73.889684 73.728 0 163.84 0h696.32zM268.126316 553.121684c93.049263-10.374737 180.062316 26.974316 283.270737 78.874948-74.886737 95.501474-165.941895 155.701895-256.970106 155.701894-157.830737 0-204.368842-126.652632-125.466947-197.200842 26.300632-22.851368 72.838737-35.301053 99.166316-37.376z" fill="#00A0EA" p-id="6328"></path></svg>
							<svg t="1685155931669" class="pay-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1648" width="26" height="26"><path d="M81.6 385.6c-12 36.8-15.2 76.8-15.2 116.8 0 251.2 199.2 454.4 445.6 454.4 245.6 0 445.6-203.2 445.6-454.4 0-183.2-106.4-341.6-260-413.6-56.8-26.4-108.8-32.8-120-3.2-10.4 30.4 30.4 59.2 60 72.8 29.6 13.6 110.4 52 106.4 128-3.2 76-121.6 84.8-192 55.2-69.6-28.8-171.2-72-195.2-52s-28 70.4 28 104c56.8 33.6 180.8 101.6 198.4 187.2 17.6 85.6 4.8 256.8-241.6 184C284.8 748 224 658.4 206.4 619.2c-50.4-112.8 9.6-226.4 32-260 32-48.8 32-96.8-24.8-117.6-54.4-20-98.4 39.2-132 144z" fill="#30B4FF" p-id="1649"></path><path d="M576.8 167.2c40.8 16 62.4 54.4 48 85.6-14.4 31.2-59.2 44-100 28s-62.4-54.4-48-85.6c14.4-31.2 59.2-44 100-28z" fill="#30B4FF" p-id="1650"></path></svg>
							<!-- <img style="width:26px;height:26px;" :src="require('@/assets/yun_pay.png')" alt=""> -->
							<!-- <svg t="1685156044947" class="pay-icon" viewBox="0 0 1325 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2568" width="32" height="34"><path d="M342.874353 817.543529l87.341176-376.470588h-3.011764c-3.011765 0-7.529412 1.505882-10.541177 3.011765-1.505882 7.529412-6.023529 28.611765-9.035294 37.647059-4.517647 19.576471-4.517647 22.588235-6.023529 33.129411l-1.505883 1.505883h-37.647058l-1.505883-1.505883 9.035294-36.141176c7.529412-33.129412 9.035294-45.176471 12.047059-61.741176l1.505882-1.505883c16.564706-3.011765 21.082353-3.011765 40.658824-6.023529l1.505882 1.505882-3.011764 10.541177c3.011765-1.505882 6.023529-4.517647 9.035294-6.02353 1.505882-1.505882 3.011765-1.505882 6.023529-3.011765l45.176471-191.247058c9.035294-42.164706 51.2-75.294118 91.858823-75.294118h-274.070588c-42.164706 0-82.823529 33.129412-91.858823 75.294118l-138.541177 596.329411c-9.035294 42.164706 16.564706 75.294118 57.223529 75.294118h272.564706c-42.164706 0-67.764706-34.635294-57.223529-75.294118z m-27.105882-313.223529c-13.552941 7.529412-33.129412 12.047059-54.211765 12.047059-16.564706 0-45.176471-3.011765-54.211765-19.576471-4.517647-6.023529-6.023529-12.047059-6.023529-19.57647l3.011764-27.105883 1.505883-7.529411 22.588235-97.882353 1.505882-6.02353s7.529412 1.505882 49.694118 0v1.505883c-4.517647 12.047059-25.6 97.882353-25.6 97.882352l-4.517647 25.6v4.517648c1.505882 12.047059 9.035294 19.576471 22.588235 19.57647 9.035294 0 15.058824-3.011765 22.588236-7.529412 10.541176-9.035294 13.552941-22.588235 18.070588-42.164706 0 0 21.082353-94.870588 21.082353-100.894117 3.011765 0 12.047059 1.505882 42.164706 0v1.505882c-4.517647 12.047059-25.6 102.4-25.6 102.4l-3.011765 9.035294c-3.011765 19.576471-9.035294 40.658824-31.623529 54.211765z" fill="#D43634" p-id="2569"></path><path d="M669.650824 817.543529l22.588235-99.388235H665.133176c-4.517647 0-7.529412 0-10.541176-1.505882-3.011765-1.505882-6.023529-4.517647-6.023529-7.529412s1.505882-7.529412 3.011764-13.552941l46.682353-153.6h33.129412l-4.517647 16.564706 4.517647-4.517647 9.035294-37.647059h-21.082353v-1.505883c1.505882-6.023529 3.011765-13.552941 4.517647-19.57647l1.505883-9.035294c3.011765-13.552941 6.023529-30.117647 6.023529-36.141177 0-3.011765 1.505882-10.541176-7.529412-10.541176-3.011765 0-7.529412 1.505882-12.047059 3.011765-1.505882 7.529412-6.023529 28.611765-9.035294 37.647058-4.517647 19.576471-4.517647 22.588235-6.023529 33.129412l-1.505882 1.505882h-37.647059l-1.505883-1.505882 9.035294-36.141176c7.529412-33.129412 9.035294-45.176471 10.541177-61.741177l1.505882-1.505882c16.564706-3.011765 21.082353-3.011765 40.658824-6.02353l1.505882 1.505883-3.011765 10.541176c3.011765-1.505882 6.023529-4.517647 9.035295-6.023529 9.035294-4.517647 18.070588-6.023529 24.094117-6.02353 4.517647 0 9.035294 0 13.552941 3.011765l43.670589-191.247059c9.035294-42.164706 51.2-75.294118 93.364706-75.294117h-326.776471c-42.164706 0-82.823529 33.129412-91.858824 75.294117l-43.670588 191.247059c7.529412-3.011765 13.552941-3.011765 18.070588-3.011765 7.529412 0 16.564706 3.011765 21.082353 12.047059 3.011765 9.035294 1.505882 19.576471-3.011764 39.152941l-3.011765 10.541177c-4.517647 22.588235-6.023529 27.105882-7.529412 42.164706l-4.517647 4.517647h-37.647059v-1.505883c1.505882-6.023529 3.011765-13.552941 4.517647-19.57647l1.505883-9.035294c3.011765-13.552941 6.023529-30.117647 6.023529-36.141177 0-3.011765 1.505882-9.035294-4.517647-10.541176l-87.341176 376.470588c-9.035294 42.164706 16.564706 75.294118 57.223529 75.294118h328.282353c-40.658824 1.505882-66.258824-33.129412-57.223529-73.788236z m12.047058-263.529411l-7.529411 24.094117h-52.705883l-6.023529 4.517647c-3.011765 3.011765-3.011765 1.505882-6.02353 3.011765s-9.035294 4.517647-18.070588 4.517647h-16.564706l7.529412-22.588235h4.517647c4.517647 0 7.529412 0 9.035294-1.505883 1.505882-1.505882 3.011765-3.011765 6.02353-7.529411l9.035294-18.070589h39.152941l-6.023529 13.552942h37.647058z m-140.047058-124.988236l-7.529412 30.117647c-1.505882 6.023529-3.011765 13.552941-4.517647 19.576471-3.011765 13.552941-4.517647 19.576471-6.02353 22.588235-1.505882 3.011765-1.505882 6.023529-3.011764 13.552941h-43.670589c1.505882-7.529412 3.011765-10.541176 4.517647-13.552941s1.505882-6.023529 4.517647-13.552941c3.011765-10.541176 4.517647-18.070588 6.02353-25.6 1.505882-6.023529 4.517647-24.094118 6.023529-30.117647-1.505882-4.517647 1.505882-9.035294 7.529412-13.552941 9.035294-6.023529 22.588235-7.529412 31.623529-3.011765 6.023529 3.011765 7.529412 9.035294 4.517648 13.552941z m7.529411 34.635294c3.011765-13.552941 9.035294-28.611765 19.576471-39.152941 16.564706-15.058824 36.141176-15.058824 45.17647-15.058823 13.552941 0 28.611765 3.011765 36.141177 13.552941 4.517647 6.023529 9.035294 18.070588 4.517647 40.658823-1.505882 7.529412-6.023529 24.094118-16.564706 34.635295-13.552941 13.552941-30.117647 18.070588-48.188235 18.070588-6.023529 0-16.564706-1.505882-24.094118-4.517647-22.588235-9.035294-19.576471-33.129412-16.564706-48.188236z m81.317647 254.494118h-43.670588c-3.011765 0-6.023529 0-10.541176-1.505882-3.011765-1.505882-6.023529-3.011765-7.529412-4.517647-1.505882-3.011765-4.517647-4.517647-3.011765-10.541177l12.047059-42.164706h-21.082353l7.529412-24.094117h21.082353l6.023529-19.576471h-21.082353l7.529412-22.588235h94.870588l-7.529412 22.588235h-37.647058l-6.02353 19.576471h39.152941l-6.023529 24.094117h-39.152941l-9.035294 31.62353c-1.505882 3.011765 9.035294 4.517647 13.552941 4.517647l19.57647-3.011765-9.035294 25.6z" fill="#034582" p-id="2570"></path><path d="M723.862588 566.061176l-7.529412 25.6s3.011765-1.505882 6.02353-4.517647l4.517647-21.082353h-3.011765z m-129.505882-72.282352c4.517647 0 7.529412-3.011765 10.541176-7.529412 4.517647-6.023529 7.529412-21.082353 9.035294-24.094118 4.517647-18.070588 3.011765-28.611765-6.023529-28.611765-12.047059 0-16.564706 15.058824-21.082353 31.62353-1.505882 6.023529-3.011765 12.047059-3.011765 16.564706 3.011765 12.047059 10.541176 12.047059 10.541177 12.047059z m94.870588 189.741176c-1.505882 4.517647-1.505882 7.529412-1.505882 7.529412 1.505882 1.505882 3.011765 3.011765 4.517647 3.011764h4.517647l13.552941-58.729411h-7.529412l-13.552941 48.188235z m24.094118-81.317647l-3.011765 10.541176h7.529412l3.011765-10.541176h-7.529412z" fill="#034582" p-id="2571"></path><path d="M967.815529 493.778824c4.517647 0 12.047059-3.011765 15.058824-7.529412 1.505882-1.505882 3.011765-6.023529 4.517647-9.035294 1.505882-4.517647 3.011765-10.541176 3.011765-15.058824 1.505882-3.011765 1.505882-6.023529 1.505882-9.035294 1.505882-12.047059-3.011765-19.576471-10.541176-19.576471-12.047059 0-16.564706 15.058824-21.082353 31.62353-1.505882 6.023529-3.011765 12.047059-3.011765 16.564706 3.011765 12.047059 10.541176 12.047059 10.541176 12.047059z m-203.294117 118.964705l3.011764-10.541176h-48.188235l-3.011765 10.541176h40.658824c6.023529 0 7.529412 1.505882 7.529412 0z" fill="#107C84" p-id="2572"></path><path d="M1198.215529 147.425882h-296.658823c-42.164706 0-82.823529 33.129412-93.364706 75.294118l-43.670588 191.247059c3.011765 1.505882 6.023529 4.517647 7.529412 9.035294 3.011765 9.035294 1.505882 19.576471-3.011765 39.152941l-3.011765 10.541177c-4.517647 22.588235-6.023529 27.105882-7.529412 42.164705l-1.505882 1.505883h-16.564706l-9.035294 37.647059c3.011765-3.011765 9.035294-6.023529 12.047059-7.529412 7.529412-3.011765 24.094118-6.023529 24.094117-6.02353h52.705883l-18.070588 60.235295c-3.011765 10.541176-6.023529 16.564706-9.035295 19.57647-1.505882 3.011765-4.517647 6.023529-9.035294 9.035294-4.517647 3.011765-9.035294 4.517647-12.047058 4.517647h-60.235295l-13.552941 58.729412 18.070588-1.505882-7.529411 27.105882h-15.058824l-24.094117 99.388235c-9.035294 42.164706 16.564706 75.294118 57.223529 75.294118h296.658823c42.164706 0 82.823529-33.129412 93.364706-75.294118l138.541177-594.823529c9.035294-42.164706-16.564706-75.294118-57.22353-75.294118z m-212.329411 263.529412c6.023529 3.011765 10.541176 6.023529 13.552941 10.541177v-4.517647l1.505882-1.505883c18.070588-3.011765 22.588235-3.011765 42.164706-6.023529v1.505882c-3.011765 13.552941-7.529412 28.611765-10.541176 42.164706-7.529412 30.117647-9.035294 45.176471-12.047059 60.235294l-1.505883 1.505882h-39.152941l-1.505882-1.505882c0-1.505882 1.505882-4.517647 1.505882-6.023529-6.023529 4.517647-12.047059 9.035294-19.57647 9.035294s-13.552941-1.505882-21.082353-4.517647c-22.588235-9.035294-19.576471-34.635294-16.564706-48.188236 3.011765-13.552941 9.035294-28.611765 19.57647-39.152941 16.564706-13.552941 34.635294-16.564706 43.670589-13.552941z m-204.8 105.411765l28.611764-118.964706 12.047059-54.211765s1.505882-4.517647 1.505883-6.023529c6.023529 0 18.070588 1.505882 51.2 0h12.047058c25.6 0 46.682353 0 58.729412 15.058823 4.517647 6.023529 6.023529 13.552941 6.02353 21.082353 0 6.023529-1.505882 12.047059-1.505883 16.564706-4.517647 19.576471-15.058824 36.141176-28.611765 46.682353-21.082353 16.564706-49.694118 16.564706-73.788235 16.564706h-3.011765l-3.011764 3.011765c0 1.505882-6.023529 24.094118-6.02353 24.094117s-6.023529 31.623529-7.529411 37.647059c-7.529412-1.505882-19.576471-1.505882-46.682353-1.505882z m10.541176 137.035294c-1.505882 4.517647-3.011765 7.529412-6.023529 10.541176-3.011765 3.011765-7.529412 6.023529-18.070589 6.02353h-18.070588v16.564706c0 4.517647 1.505882 4.517647 1.505883 4.517647s1.505882 1.505882 3.011764 1.505882h6.02353l18.070588-1.505882-9.035294 27.105882h-19.576471c-13.552941 0-24.094118 0-28.611764-3.011765-3.011765-1.505882-4.517647-4.517647-3.011765-9.035294l1.505882-64.752941h31.62353v13.552941h7.529411c3.011765 0 4.517647 0 6.02353-1.505882 1.505882-1.505882 1.505882-1.505882 1.505882-3.011765l3.011765-10.541176h25.6l-3.011765 13.552941z m111.435294 64.752941h-34.635294l3.011765-7.529412h-69.270588l7.529411-22.588235h7.529412l36.141177-121.976471 7.529411-24.094117h34.635294l-3.011764 12.047059s9.035294-6.023529 18.070588-9.035294c7.529412-1.505882 43.670588-3.011765 55.717647-3.011765h37.647059v13.552941c0 3.011765 1.505882 3.011765 6.023529 3.011765h6.02353l-6.02353 24.094117h-19.57647c-18.070588 1.505882-24.094118-6.023529-24.094118-15.058823v-13.552941l-3.011765 12.047058h-12.047058l-36.141177 120.470589h9.035294l-7.529412 24.094117h-10.541176l-3.011765 7.529412z m155.105883-106.917647h-37.647059l-6.02353 19.576471h37.647059l-6.023529 19.57647h-40.658824l-7.529412 9.035294h16.564706l4.517647 25.6c0 3.011765 0 4.517647 1.505883 6.02353 1.505882 1.505882 6.023529 1.505882 9.035294 1.505882h4.517647l-7.529412 25.6h-21.082353c-4.517647 0-6.023529-3.011765-9.035294-4.517647-3.011765-1.505882-6.023529-4.517647-6.023529-9.035294l-4.517647-25.6-18.070589 25.6c-6.023529 7.529412-13.552941 13.552941-27.105882 13.552941h-25.6l7.529412-22.588235h10.541176c3.011765 0 6.023529-1.505882 7.529412-1.505883 1.505882-1.505882 3.011765-1.505882 6.023529-4.517647l27.105883-37.647058h-36.141177l6.02353-21.082353h40.658823l6.02353-19.576471h-40.658824l7.529412-22.588235h112.941176l-12.047058 22.588235z m24.094117-70.776471l-1.505882 1.505883-15.058824 25.6c-4.517647 9.035294-13.552941 15.058824-27.105882 15.058823h-22.588235l7.529411-22.588235h4.517648c3.011765 0 4.517647 0 6.023529-1.505882 1.505882 0 1.505882-1.505882 3.011765-3.011765l7.529411-13.552941c12.047059-18.070588 15.058824-25.6 27.105883-45.176471-1.505882-22.588235-3.011765-30.117647-4.517647-43.670588-1.505882-9.035294-3.011765-18.070588-3.011765-27.105882-1.505882-18.070588-1.505882-15.058824-4.517647-27.105883v-1.505882l1.505882-1.505882c18.070588-1.505882 18.070588-3.011765 37.647059-6.02353l1.505882 1.505883 3.011765 49.694117v3.011765c10.541176-22.588235 10.541176-16.564706 22.588235-45.176471v-1.505882l1.505883-1.505882c16.564706-1.505882 19.576471-3.011765 39.152941-6.02353l1.505882 1.505883c-1.505882 0-75.294118 128-85.835294 149.082352z" fill="#107C84" p-id="2573"></path><path d="M775.062588 579.614118l4.517647-13.552942h-51.2l-4.517647 21.082353c7.529412-4.517647 15.058824-7.529412 22.588236-7.529411h28.611764z m105.411765-159.62353c10.541176-4.517647 18.070588-15.058824 19.576471-27.105882 3.011765-13.552941-1.505882-22.588235-10.541177-27.105882l-25.6-1.505883h-4.517647V368.790588l-12.047059 52.705883v3.011764h6.02353c9.035294 0 19.576471 0 27.105882-4.517647z m-28.611765 266.541177h28.611765l7.529412-27.105883h-28.611765l-7.529412 27.105883z m36.141177-120.470589l-9.035294 30.117648s10.541176-4.517647 16.564705-6.02353c6.023529-1.505882 15.058824-1.505882 15.058824-1.505882l6.023529-22.588236h-28.611764z m-24.094118 76.8s10.541176-6.023529 16.564706-7.529411c6.023529-1.505882 15.058824-3.011765 15.058823-3.011765l7.529412-22.588235h-28.611764l-10.541177 33.129411z" fill="#107C84" p-id="2574"></path></svg> -->
						</div>
						<div class="code">
							<div id="payQrCode"></div>
						</div>
					</div>
					<div class="code-wrap" v-show="nowSelPayType=='online'&&showSureOnlinePay">
						<div class="lastpay">
							<button @click.stop="lastPay">确认支付</button>
						</div>
					</div>
					<div class="code-wrap" v-show="nowSelPayType=='last'">
						<div class="last-pay-info">
							<span class="tit" style="font-size:16px">余额:</span>
							<span class="val" style="color:#fd8d20" v-if="personData && personData.memberAccount">{{personData.memberAccount.totalAmount}}</span>
						</div>
						<div class="lastpay">
							<button @click.stop="lastPay">确认支付</button>
						</div>
					</div>
				</div>
				<div class="bottom" v-if="storeInfo.deliveryEnabled">
					<span class="tip">温馨提示</span>
					<span class="tip-info">商品付款成功后，会有服务员送到您的位置！</span>
				</div>
			</div>
		</div>
		<!-- end new pa -->
		<div class="balanceMask mask" v-if="false">
			<div class="balanceBox box position-middle-center">
				<div class="title">结算<span class="closeBtn" @click="showBalance=false;">&times;</span></div>
				<div class="balanceInner">
					<div class="orderMsg clearfix">
						<div class="name left">支付详情</div>
						<div class="msg left">
							<!-- <div class="msgItem clearfix" v-if="personData"> -->
								<!-- <div class="msgName left">选择优惠券：</div> -->
								<!-- <div class="msgData right" style="cursor:pointer;color:#ff4f3d" @click="openCoupon">{{curBindCoupon[0]?curBindCoupon[0].couponName:'选择优惠券'}}<span class="reliveCoupon" @click.stop="relieveCoupon(curBindCoupon[0])" v-if="curBindCoupon[0]">x</span></div> -->
								<!-- <div class="couponBox right" id="couponBox">
									<div class="selCoupon" @click="triggerCoupon()"><span v-text="curBindCoupon.title"></span><i class="iconfont icon-sanjiaoxing"></i></div>
									<ul class="couponList">
										<li @click="selCoupon()">无优惠</li>
										<li v-for="(item,idx) in couponList" :key="idx" :title="item.title+'（'+item.productName+'）'" v-text="item.title+'（'+item.productName+'）'" @click="selCoupon(item)"></li>
									</ul>
								</div> -->
							<!-- </div> -->
							<div class="msgItem clearfix">
								<div class="msgName left">总金额：</div>
								<div class="msgData right" v-text="'￥'+totalPrice.total.toFixed(2)"></div>
							</div>
							<div class="msgItem clearfix">
								<div class="msgName left">折扣：</div>
								<div class="msgData right" v-text="'￥'+totalPrice.discount.toFixed(2)"></div>
							</div>
							<div class="msgItem clearfix">
								<div class="msgName left">应付金额：</div>
								<div style="color: #ff4f3d;" class="msgData right" v-text="'￥'+totalPrice.amount.toFixed(2)"></div>
							</div>
						</div>
					</div>
					<div class="orderMsg clearfix" style="padding:20px 0;" v-if="personData">
						<div class="name left">会员信息</div>
						<div class="msg left">
							<div class="msgItem clearfix" style="padding-bottom:10px;">
								<div class="msgName left">会员名称：</div>
								<div class="msgData right">{{personData.name}}</div>
							</div>
							<div class="msgItem clearfix">
								<div class="msgName left">余额：</div>
								<div class="msgData right">{{personData.memberAccount.totalAmount}}</div>
							</div>
							<div class="msgItem clearfix">
								<div class="msgName left">选择优惠券：</div>
								<div class="msgData right" style="cursor:pointer;color:#ff4f3d" @click="openCoupon">{{curBindCoupon[0]?curBindCoupon[0].couponName:'选择优惠券'}}<span class="reliveCoupon" @click.stop="relieveCoupon(curBindCoupon[0])" v-if="curBindCoupon[0]">x</span></div>
							</div>
						</div>
					</div>
					<div class="clickToPay clearfix">
						<div class="name left">点击付款</div>
						<div class="payType left">
							<span class="color1" v-if="!personData" @click="beforePayByAlipayOrWechat(true)"></span>
							<span class="color2" v-if="!personData" @click="beforePayByAlipayOrWechat(false)"></span>
							<span class="color3" @click="goVipPay()">
								<!-- <div class="vipCheckMask" v-if="showVipCheckMask">
									<p>请输入验证码</p>
									<input type="tel" v-model="identifyingCode">
									<button type="button">确定</button>
								</div> -->
							</span>
							<!-- <span class="color4 freeMoney" @click="goVipPay()">
								余额支付
							</span> -->
						</div>
					</div>
				</div>
			</div>
		</div>
		<!-- 自定义网费 -->
		<div class="delConfirmMask mask customPrice" @click="customPriceBtn=false;customPrice=''" v-if="customPriceBtn">
			<div class="delConfirmBox box position-middle-center" @click.stop="">
				<div class="title">请输入网费金额</div>
				<div class="inputMoney" id="inputMoney"><input type="text" v-model="customPrice" placeholder="请输入网费"></div>
				<div class="btnGroup">
					<button type="button" class="cancle" @click="customPriceBtn=false;customPrice=''">取消</button>
					<button type="button" class="save" @click="addProduct( $event, '0', true );changeNowSelectCount(selItem,false,'add')">确定</button>
				</div>
			</div>
		</div>
		<!-- 支付宝微信二维码 -->
		<div class="codeMask mask" v-if="false">
			<div class="codeBox box position-middle-center" v-if="payMode=='THIRD_PARTY'">
				<div class="title">支付<!-- <span class="closeBtn" @click="closeCode">&times;</span> --></div>
				<div class="codeImgBox no-hus" id="payQrCode" v-if="nowType!='HUI_SHANG'">
				</div>
				<div class="codeImgBox HUI_SHANG" v-if="nowType=='HUI_SHANG'">
					<img :src="payImgUrl" alt=""  >
				</div>
				<p>请用手机扫码进行支付</p>
				<p>请在3分钟内进行支付，过时将自动取消。</p>
				<div class="returnBtn">
					<button type="button" @click="showDelConfirm=true">取消支付</button>
				</div>
			</div>
			<div class="codeBox box position-middle-center" v-if="payMode=='CASHIER'">
				<div class="title">支付<!-- <span class="closeBtn" @click="closeCode">&times;</span> --></div>
				<div class="codeImgBox" style="margin-top:20px;">
					<img :src="payImgUrl" alt="" >
				</div>
				<p v-text="'￥'+totalPrice.amount" style="color:#ff4f3d;font-size:32px;font-weight:600;margin-bottom:20px;"></p>
				<p>请尽快支付，完成后点击确认。</p>
				<div class="returnBtn">
					<button type="button" @click="showCode=false;" style="background-color:#adabab;box-shadow:0 0 4px 0 #adabab;">取消支付</button>
					<button type="button" @click="cashierPay">确认支付</button>
				</div>
			</div>
		</div>
		<!-- 会员支付 -->
		<div class="codeMask mask" v-if="showVipPayCode">
			<div class="codeBox box position-middle-center">
				<div class="title">支付<!-- <span class="closeBtn" @click="closeCode">&times;</span> --></div>
				<div class="codeImgBox">
					<div id="vipQRCode">
						
					</div>
				</div>
				<p>请用<span style="color:red;font-size:20px;">微信扫码</span>进行支付</p>
				<div class="returnBtn">
					<button type="button" @click="showDelConfirm=true">取消支付</button>
				</div>
			</div>
		</div>
		<!-- 用户安全登录 -->
		<div class="codeMask mask" v-if="showLoding">
			<div class="codeBox new box position-middle-center">
				<div class="title">会员登录<span class="closeBtn" @click="closePersonBox()">&times;</span></div>
				<div class="phone-box">
					<el-input type="primary" v-model="inpPhone" placeholder="请输入手机号..."></el-input>
				</div>
				<div class="phone-code">
					<el-input type="primary" v-model="phoneCode" style="border-color:#333;" placeholder="请输入验证码...">
						<el-button slot="append" @click.stop="getCode" style="cursor:pointer;">{{btnInfo}}</el-button>
					</el-input>
				</div>
				<div class="btn">
					<span @click.stop="memberLogin" style="cursor:pointer;">登录</span>
				</div>
				<p style="color:red;font-size:12px;">请输入手机号后获取验证码进行会员登录</p>
			</div>
		</div>
		<!-- <div class="codeMask mask" v-if="showLoding">
			<div class="codeBox box position-middle-center">
				<div class="title">安全登录<span class="closeBtn" @click="closePersonBox()">&times;</span></div>
				<div class="codeImgBox">
					<div id="qrcode">
						
					</div>
				</div>
				<p>请用<span style="color:red;font-size:20px;">微信扫码</span>进行安全登录</p>
			</div>
		</div> -->
		<!-- 确认取消支付 -->
		<div class="delConfirmMask mask" v-if="showDelConfirm" @click="showDelConfirm=false">
			<div class="delConfirmBox box position-middle-center" @click.stop="">
				<div class="title">注意</div>
				<p>订单支付中，确定取消支付？</p>
				<div class="btnGroup">
					<button type="button" class="cancle" @click="showDelConfirm=false">取消</button>
					<button type="button" class="save" @click="cancelPayment()">确定</button>
				</div>
			</div>
		</div>
		<!-- 支付成功 -->
		<div class="successMask mask" v-if="showPaySuccess" @click="refresh()">
			<div class="successBox box position-middle-center" @click.stop="">
				<div class="title">完成<span class="closeBtn" @click="refresh()">&times;</span></div>
				<div class="successInner clearfix">
					<div class="leftImg left">
						<img src="../../assets/success.png" height="120" width="120" alt="">
					</div>
					<div class="rightMsg left">
						<span v-text="'您已成功支付'+oldAmountPrice.toFixed(2)+'元。'"></span>
						<span>商品即将达到，请耐心等待</span>
					</div>
				</div>
			</div>
		</div>
		<div class="topAndRefresh">
			<!-- <div class="refresh" @click="noticeFn()" style="color:red;">
				<i class="iconfont icon-kefu"></i>
				<p>呼叫</p>
			</div> -->
			<!-- <div class="refresh" @click="choiceArr.length<=0?'':showCarDetail=true"> -->
				<!-- <i class="iconfont icon-gouwuche"></i> -->
				<!-- <p>购物车</p> -->
				<!-- <span class="sel-goods-count" v-if="goodLength>0" v-text="goodLength"></span> -->
			<!-- </div> -->
			<div class="refresh" @click="refresh()">
				<i class="iconfont icon-shuaxin"></i>
				<!-- <p>刷新页面</p> -->
			</div>
			<div class="goTop" @click="goTop()">
				<i class="iconfont icon-fanhuidingbu"></i>
				<!-- <p>返回顶部</p> -->
			</div>
		</div>
		<!-- <el-dialog
            title="配品"
            :visible.sync="showPeiGoods"
            width="49%"
            >
            <div class="pei-wrap">
                <el-table
                    :data="peiGoods"
                    style="width: 100%">
                    <el-table-column
                        prop="name"
                        label="名称"
                        >
                    </el-table-column>
                    <el-table-column
                        prop="salesPrice"
                        label="价格"
                        >
                    </el-table-column>
                    <el-table-column
                        prop="selCount"
                        label="所选数量"
                       >
                        <template slot-scope="scope">
                            <span style="color:red;">{{scope.row.selCount}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column
                        width="180"
                        label="操作">
                        <template slot-scope="scope">
                            <el-button size="mini" type="primary" @click="modifyPeiGoods('reduce',scope.row)">删除</el-button>
                            <el-button size="mini" type="primary" @click="modifyPeiGoods('add',scope.row)">添加</el-button>
                        </template>
                    </el-table-column>
                    </el-table>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="showPeiGoods = false">取 消</el-button>
                <el-button type="primary" @click="submitSelPei">确 定</el-button>
            </span>
        </el-dialog> -->
		<!-- 配品 -->
        <el-dialog
			:title="nowSelNeedPeiItem?`选择配品-${nowSelNeedPeiItem.productName}`:'--'"
            :visible.sync="showPeiGoods"
            :close-on-click-modal="false"
            width="500px"
            >
            <div class="pei-wrap">
                <div class="pei-item" :class="{active:nowSelPeiGoodsIds.indexOf(it.id)!=-1}" v-for="(it,ind) in peiGoods" @click="modifyPeiGoods('add',it)" :key="ind">
                    <div class="item-name">{{it.name}}</div>
                    <div class="item-price">￥{{it.salesPrice}}</div>
                </div>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="showPeiGoods = false">跳 过</el-button>
                <el-button type="primary" @click="submitSelPei">选好了</el-button>
            </span>
        </el-dialog>
		<!-- 规格 -->
        <el-dialog
            :title="nowSelNeedSpecItem?`选择规格-${nowSelNeedSpecItem.name}`:'--'"
            :visible.sync="showSelSpec"
            :close-on-press-escape="false"
            :close-on-click-modal="false"
            :show-close="false"
            width="500px"
            >
            <div class="pei-wrap" v-for="(item,index) in specs" :key="index">
                <div class="spec-name">{{item.name}}</div>
                <div class="pei-item" :class="{active:(item.seledSpec&&item.seledSpec==it)}" v-for="(it,ind) in item.specs" :key="`_${ind}`" @click="modifySpecs('add',it,item)" >
                    <div class="item-name">{{it}}</div>
                </div>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="beforeCloseSpec">取 消</el-button>
                <el-button type="primary" @click="submitSelSpec($event)">确 定</el-button>
            </span>
        </el-dialog>
        <!--  -->
		<el-dialog
			title="请选择你喜欢的配送人员"
			:visible.sync="showSelEmp"
			:close-on-press-escape="false"
			:close-on-click-modal="false"
			:show-close="true"
			width="700px"
		>
			<div class="emp-wrap" v-if="emps && emps.length">
				<div class="emp-item" v-for="(it,ind) in emps" :key="ind">
					<div class="item-inner-wrap">
						<div class="item-avatar">
							<el-image
							style="width: 100px; height: 100px;border-radius:50px;"
							:src="it.photo+'?x-oss-process=image/resize,l_300'"
							:preview-src-list="[it.photo]"
							:fit="'cover'"></el-image>
						</div>
						<div class="item-name">{{it.name}}</div>
						<span class="btn" @click.stop="toSelEmp(it)">选择TA</span>
					</div>
				</div>
			</div>
			<div class="emp-wrap" v-else style="text-align:center;">
				暂无配送人员，请联系吧台。
			</div>
		</el-dialog>
		<!--  -->
		<div class="vipCouponMask" v-if="showSelCoupon" @click="showSelCoupon=false">
            <div class="vipCouponBox" @click.stop="">
                <div class="title">会员优惠券</div>
                <div class="vipMsg clearfix">
                    <div class="name left">会员名称：</div>
                    <div class="val left" v-text="personData.name"></div>
                    <div class="name left">会员帐号：</div>
                    <div class="val left" v-text="personData.mobile?personData.mobile:personData.code"></div>
                </div>
                <div class="selCouponBox">
                    <div class="coupon-scroll-box">
                        <div class="item" v-for="(item,idx) in couponList" @click.stop="selCouponItem(item,idx)" :key="idx" :class="{active:idx==curCouponIdx}">
                            <el-dropdown @command="handleCommand" trigger="click">
                                <div>
                                    <span class="coupon_title" v-text="item.title"></span>
                                    <div class="left typeAddProduct">
                                        <span class="typeName" v-text="couponType[item.type]"></span>
                                        <span>-</span>
                                        <span v-text="item.productName"></span>
                                    </div>
                                    <div class="deadLine">
                                        <span>有效日期：</span>
                                        <span>{{item.beginTime | numberToAllDate('')}}</span>
                                        <span>~</span>
                                        <span>{{item.endTime | numberToAllDate('')}}</span>
                                    </div>
                                </div>
								<el-dropdown-menu slot="dropdown" style="opacity:0;">
                                    <el-dropdown-item></el-dropdown-item>
                                </el-dropdown-menu>
                                <el-dropdown-menu slot="dropdown" v-if="item.products && item.products.length>1">
                                    <el-dropdown-item :command="it" v-for="(it,ind) in item.products" :key="ind">{{it.productName}}</el-dropdown-item>
                                </el-dropdown-menu>
                            </el-dropdown>
                        </div>
                    </div>
                    <div class="btnGroup" style="color:red;" v-if="nowSelCouponItem&&nowSelCouponItem.productName">
                        <span>*当前选择的优惠券抵扣商品是：{{nowSelCouponItem.productName}}</span>
                    </div>
                    <div class="btnGroup">
                        <button type="button" class="cancel" @click="showSelCoupon=false">取消</button>
                        <button type="button" class="save" @click="choiceCoupon()">确认</button>
                    </div>
                </div>
            </div>
        </div>
		<!--  -->
		<div class="order-loading" v-if="showOrderLoading">
			<div class="wrap">
				<span v-if="orderOverTime>0">订单支付中<span class="time-count">({{orderOverTime}}s)</span>，不可修改... </span>
				<span v-if="orderOverTime<=0">支付超时，请重新点单！如已支付，请联系工作人员！</span>
				<!-- <div class="btn">
					<span class="re" @click.stop="reCreateOrder" :class="{active:orderOverTime <= 0}">重新点单</span>
				</div> -->
			</div>
		</div>
		<!--  -->
		<div class="balance-wrap" v-if="showPayCodeBoxForRent">
			<div class="inner-banlance-wrap">
				<div class="tit-wrap">
					<span class="tit">收银台</span>
					<span class="close" @click="closeBalanceForRent">&times;</span>
				</div>
				<div class="pay-wrap">
					<div class="code-wrap" v-show="nowSelPayType=='online'">
						<div class="tit">
							<span>支持付款：</span>
							<svg t="1684984764690" class="pay-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4549" width="26" height="26"><path d="M352.814545 385.396364m-33.512727 0a33.512727 33.512727 0 1 0 67.025455 0 33.512727 33.512727 0 1 0-67.025455 0Z" fill="#50B674" p-id="4550"></path><path d="M502.690909 384.465455m-33.512727 0a33.512727 33.512727 0 1 0 67.025454 0 33.512727 33.512727 0 1 0-67.025454 0Z" fill="#50B674" p-id="4551"></path><path d="M576.232727 534.341818m-23.272727 0a23.272727 23.272727 0 1 0 46.545455 0 23.272727 23.272727 0 1 0-46.545455 0Z" fill="#50B674" p-id="4552"></path><path d="M694.458182 536.203636m-23.272727 0a23.272727 23.272727 0 1 0 46.545454 0 23.272727 23.272727 0 1 0-46.545454 0Z" fill="#50B674" p-id="4553"></path><path d="M512 0C229.003636 0 0 229.003636 0 512s229.003636 512 512 512 512-229.003636 512-512S794.996364 0 512 0z m-87.505455 630.225455c-26.996364 0-48.407273-5.585455-75.403636-11.17091l-75.403636 37.236364 21.410909-64.232727c-53.992727-37.236364-85.643636-85.643636-85.643637-145.221818 0-102.4 96.814545-182.458182 215.04-182.458182 105.192727 0 198.283636 64.232727 216.901819 150.807273-6.516364-0.930909-13.963636-0.930909-20.48-0.93091-102.4 0-182.458182 76.334545-182.458182 170.356364 0 15.825455 2.792727 30.72 6.516363 44.683636-7.447273 0-13.963636 0.930909-20.48 0.93091z m314.647273 75.403636l15.825455 53.992727-58.647273-32.581818c-21.410909 5.585455-42.821818 11.170909-64.232727 11.170909-102.4 0-182.458182-69.818182-182.458182-155.461818s80.058182-155.461818 182.458182-155.461818c96.814545 0 182.458182 69.818182 182.458182 155.461818 0 47.476364-31.650909 90.298182-75.403637 122.88z" fill="#50B674" p-id="4554"></path></svg>
							<svg t="1684984787818" class="pay-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6327" width="24" height="24"><path d="M860.16 0C950.272 0 1024 73.889684 1024 164.163368v531.509895s-32.768-4.122947-180.224-53.355789c-40.96-14.362947-96.256-34.896842-157.696-57.478737 36.864-63.595789 65.536-137.485474 86.016-215.444211h-202.752v-71.841684h247.808V256.512h-247.808V135.437474h-100.352c-18.432 0-18.432 18.458947-18.432 18.458947v104.663579H200.704v41.040842h249.856v69.793684H243.712v41.013895H645.12c-14.336 51.307789-34.816 98.519579-57.344 141.608421-129.024-43.115789-268.288-77.985684-356.352-55.403789-55.296 14.362947-92.16 38.992842-112.64 63.595789-96.256 116.978526-26.624 295.504842 176.128 295.504842 120.832 0 237.568-67.718737 327.68-178.526316C757.76 742.858105 1024 853.692632 1024 853.692632v6.144C1024 950.110316 950.272 1024 860.16 1024H163.84C73.728 1024 0 950.137263 0 859.836632V164.163368C0 73.889684 73.728 0 163.84 0h696.32zM268.126316 553.121684c93.049263-10.374737 180.062316 26.974316 283.270737 78.874948-74.886737 95.501474-165.941895 155.701895-256.970106 155.701894-157.830737 0-204.368842-126.652632-125.466947-197.200842 26.300632-22.851368 72.838737-35.301053 99.166316-37.376z" fill="#00A0EA" p-id="6328"></path></svg>
							<svg t="1685155931669" class="pay-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1648" width="26" height="26"><path d="M81.6 385.6c-12 36.8-15.2 76.8-15.2 116.8 0 251.2 199.2 454.4 445.6 454.4 245.6 0 445.6-203.2 445.6-454.4 0-183.2-106.4-341.6-260-413.6-56.8-26.4-108.8-32.8-120-3.2-10.4 30.4 30.4 59.2 60 72.8 29.6 13.6 110.4 52 106.4 128-3.2 76-121.6 84.8-192 55.2-69.6-28.8-171.2-72-195.2-52s-28 70.4 28 104c56.8 33.6 180.8 101.6 198.4 187.2 17.6 85.6 4.8 256.8-241.6 184C284.8 748 224 658.4 206.4 619.2c-50.4-112.8 9.6-226.4 32-260 32-48.8 32-96.8-24.8-117.6-54.4-20-98.4 39.2-132 144z" fill="#30B4FF" p-id="1649"></path><path d="M576.8 167.2c40.8 16 62.4 54.4 48 85.6-14.4 31.2-59.2 44-100 28s-62.4-54.4-48-85.6c14.4-31.2 59.2-44 100-28z" fill="#30B4FF" p-id="1650"></path></svg>
							<img style="width:26px;height:26px;" :src="require('@/assets/yun_pay.png')" alt="">
							<!-- <svg t="1685156044947" class="pay-icon" viewBox="0 0 1325 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2568" width="32" height="34"><path d="M342.874353 817.543529l87.341176-376.470588h-3.011764c-3.011765 0-7.529412 1.505882-10.541177 3.011765-1.505882 7.529412-6.023529 28.611765-9.035294 37.647059-4.517647 19.576471-4.517647 22.588235-6.023529 33.129411l-1.505883 1.505883h-37.647058l-1.505883-1.505883 9.035294-36.141176c7.529412-33.129412 9.035294-45.176471 12.047059-61.741176l1.505882-1.505883c16.564706-3.011765 21.082353-3.011765 40.658824-6.023529l1.505882 1.505882-3.011764 10.541177c3.011765-1.505882 6.023529-4.517647 9.035294-6.02353 1.505882-1.505882 3.011765-1.505882 6.023529-3.011765l45.176471-191.247058c9.035294-42.164706 51.2-75.294118 91.858823-75.294118h-274.070588c-42.164706 0-82.823529 33.129412-91.858823 75.294118l-138.541177 596.329411c-9.035294 42.164706 16.564706 75.294118 57.223529 75.294118h272.564706c-42.164706 0-67.764706-34.635294-57.223529-75.294118z m-27.105882-313.223529c-13.552941 7.529412-33.129412 12.047059-54.211765 12.047059-16.564706 0-45.176471-3.011765-54.211765-19.576471-4.517647-6.023529-6.023529-12.047059-6.023529-19.57647l3.011764-27.105883 1.505883-7.529411 22.588235-97.882353 1.505882-6.02353s7.529412 1.505882 49.694118 0v1.505883c-4.517647 12.047059-25.6 97.882353-25.6 97.882352l-4.517647 25.6v4.517648c1.505882 12.047059 9.035294 19.576471 22.588235 19.57647 9.035294 0 15.058824-3.011765 22.588236-7.529412 10.541176-9.035294 13.552941-22.588235 18.070588-42.164706 0 0 21.082353-94.870588 21.082353-100.894117 3.011765 0 12.047059 1.505882 42.164706 0v1.505882c-4.517647 12.047059-25.6 102.4-25.6 102.4l-3.011765 9.035294c-3.011765 19.576471-9.035294 40.658824-31.623529 54.211765z" fill="#D43634" p-id="2569"></path><path d="M669.650824 817.543529l22.588235-99.388235H665.133176c-4.517647 0-7.529412 0-10.541176-1.505882-3.011765-1.505882-6.023529-4.517647-6.023529-7.529412s1.505882-7.529412 3.011764-13.552941l46.682353-153.6h33.129412l-4.517647 16.564706 4.517647-4.517647 9.035294-37.647059h-21.082353v-1.505883c1.505882-6.023529 3.011765-13.552941 4.517647-19.57647l1.505883-9.035294c3.011765-13.552941 6.023529-30.117647 6.023529-36.141177 0-3.011765 1.505882-10.541176-7.529412-10.541176-3.011765 0-7.529412 1.505882-12.047059 3.011765-1.505882 7.529412-6.023529 28.611765-9.035294 37.647058-4.517647 19.576471-4.517647 22.588235-6.023529 33.129412l-1.505882 1.505882h-37.647059l-1.505883-1.505882 9.035294-36.141176c7.529412-33.129412 9.035294-45.176471 10.541177-61.741177l1.505882-1.505882c16.564706-3.011765 21.082353-3.011765 40.658824-6.02353l1.505882 1.505883-3.011765 10.541176c3.011765-1.505882 6.023529-4.517647 9.035295-6.023529 9.035294-4.517647 18.070588-6.023529 24.094117-6.02353 4.517647 0 9.035294 0 13.552941 3.011765l43.670589-191.247059c9.035294-42.164706 51.2-75.294118 93.364706-75.294117h-326.776471c-42.164706 0-82.823529 33.129412-91.858824 75.294117l-43.670588 191.247059c7.529412-3.011765 13.552941-3.011765 18.070588-3.011765 7.529412 0 16.564706 3.011765 21.082353 12.047059 3.011765 9.035294 1.505882 19.576471-3.011764 39.152941l-3.011765 10.541177c-4.517647 22.588235-6.023529 27.105882-7.529412 42.164706l-4.517647 4.517647h-37.647059v-1.505883c1.505882-6.023529 3.011765-13.552941 4.517647-19.57647l1.505883-9.035294c3.011765-13.552941 6.023529-30.117647 6.023529-36.141177 0-3.011765 1.505882-9.035294-4.517647-10.541176l-87.341176 376.470588c-9.035294 42.164706 16.564706 75.294118 57.223529 75.294118h328.282353c-40.658824 1.505882-66.258824-33.129412-57.223529-73.788236z m12.047058-263.529411l-7.529411 24.094117h-52.705883l-6.023529 4.517647c-3.011765 3.011765-3.011765 1.505882-6.02353 3.011765s-9.035294 4.517647-18.070588 4.517647h-16.564706l7.529412-22.588235h4.517647c4.517647 0 7.529412 0 9.035294-1.505883 1.505882-1.505882 3.011765-3.011765 6.02353-7.529411l9.035294-18.070589h39.152941l-6.023529 13.552942h37.647058z m-140.047058-124.988236l-7.529412 30.117647c-1.505882 6.023529-3.011765 13.552941-4.517647 19.576471-3.011765 13.552941-4.517647 19.576471-6.02353 22.588235-1.505882 3.011765-1.505882 6.023529-3.011764 13.552941h-43.670589c1.505882-7.529412 3.011765-10.541176 4.517647-13.552941s1.505882-6.023529 4.517647-13.552941c3.011765-10.541176 4.517647-18.070588 6.02353-25.6 1.505882-6.023529 4.517647-24.094118 6.023529-30.117647-1.505882-4.517647 1.505882-9.035294 7.529412-13.552941 9.035294-6.023529 22.588235-7.529412 31.623529-3.011765 6.023529 3.011765 7.529412 9.035294 4.517648 13.552941z m7.529411 34.635294c3.011765-13.552941 9.035294-28.611765 19.576471-39.152941 16.564706-15.058824 36.141176-15.058824 45.17647-15.058823 13.552941 0 28.611765 3.011765 36.141177 13.552941 4.517647 6.023529 9.035294 18.070588 4.517647 40.658823-1.505882 7.529412-6.023529 24.094118-16.564706 34.635295-13.552941 13.552941-30.117647 18.070588-48.188235 18.070588-6.023529 0-16.564706-1.505882-24.094118-4.517647-22.588235-9.035294-19.576471-33.129412-16.564706-48.188236z m81.317647 254.494118h-43.670588c-3.011765 0-6.023529 0-10.541176-1.505882-3.011765-1.505882-6.023529-3.011765-7.529412-4.517647-1.505882-3.011765-4.517647-4.517647-3.011765-10.541177l12.047059-42.164706h-21.082353l7.529412-24.094117h21.082353l6.023529-19.576471h-21.082353l7.529412-22.588235h94.870588l-7.529412 22.588235h-37.647058l-6.02353 19.576471h39.152941l-6.023529 24.094117h-39.152941l-9.035294 31.62353c-1.505882 3.011765 9.035294 4.517647 13.552941 4.517647l19.57647-3.011765-9.035294 25.6z" fill="#034582" p-id="2570"></path><path d="M723.862588 566.061176l-7.529412 25.6s3.011765-1.505882 6.02353-4.517647l4.517647-21.082353h-3.011765z m-129.505882-72.282352c4.517647 0 7.529412-3.011765 10.541176-7.529412 4.517647-6.023529 7.529412-21.082353 9.035294-24.094118 4.517647-18.070588 3.011765-28.611765-6.023529-28.611765-12.047059 0-16.564706 15.058824-21.082353 31.62353-1.505882 6.023529-3.011765 12.047059-3.011765 16.564706 3.011765 12.047059 10.541176 12.047059 10.541177 12.047059z m94.870588 189.741176c-1.505882 4.517647-1.505882 7.529412-1.505882 7.529412 1.505882 1.505882 3.011765 3.011765 4.517647 3.011764h4.517647l13.552941-58.729411h-7.529412l-13.552941 48.188235z m24.094118-81.317647l-3.011765 10.541176h7.529412l3.011765-10.541176h-7.529412z" fill="#034582" p-id="2571"></path><path d="M967.815529 493.778824c4.517647 0 12.047059-3.011765 15.058824-7.529412 1.505882-1.505882 3.011765-6.023529 4.517647-9.035294 1.505882-4.517647 3.011765-10.541176 3.011765-15.058824 1.505882-3.011765 1.505882-6.023529 1.505882-9.035294 1.505882-12.047059-3.011765-19.576471-10.541176-19.576471-12.047059 0-16.564706 15.058824-21.082353 31.62353-1.505882 6.023529-3.011765 12.047059-3.011765 16.564706 3.011765 12.047059 10.541176 12.047059 10.541176 12.047059z m-203.294117 118.964705l3.011764-10.541176h-48.188235l-3.011765 10.541176h40.658824c6.023529 0 7.529412 1.505882 7.529412 0z" fill="#107C84" p-id="2572"></path><path d="M1198.215529 147.425882h-296.658823c-42.164706 0-82.823529 33.129412-93.364706 75.294118l-43.670588 191.247059c3.011765 1.505882 6.023529 4.517647 7.529412 9.035294 3.011765 9.035294 1.505882 19.576471-3.011765 39.152941l-3.011765 10.541177c-4.517647 22.588235-6.023529 27.105882-7.529412 42.164705l-1.505882 1.505883h-16.564706l-9.035294 37.647059c3.011765-3.011765 9.035294-6.023529 12.047059-7.529412 7.529412-3.011765 24.094118-6.023529 24.094117-6.02353h52.705883l-18.070588 60.235295c-3.011765 10.541176-6.023529 16.564706-9.035295 19.57647-1.505882 3.011765-4.517647 6.023529-9.035294 9.035294-4.517647 3.011765-9.035294 4.517647-12.047058 4.517647h-60.235295l-13.552941 58.729412 18.070588-1.505882-7.529411 27.105882h-15.058824l-24.094117 99.388235c-9.035294 42.164706 16.564706 75.294118 57.223529 75.294118h296.658823c42.164706 0 82.823529-33.129412 93.364706-75.294118l138.541177-594.823529c9.035294-42.164706-16.564706-75.294118-57.22353-75.294118z m-212.329411 263.529412c6.023529 3.011765 10.541176 6.023529 13.552941 10.541177v-4.517647l1.505882-1.505883c18.070588-3.011765 22.588235-3.011765 42.164706-6.023529v1.505882c-3.011765 13.552941-7.529412 28.611765-10.541176 42.164706-7.529412 30.117647-9.035294 45.176471-12.047059 60.235294l-1.505883 1.505882h-39.152941l-1.505882-1.505882c0-1.505882 1.505882-4.517647 1.505882-6.023529-6.023529 4.517647-12.047059 9.035294-19.57647 9.035294s-13.552941-1.505882-21.082353-4.517647c-22.588235-9.035294-19.576471-34.635294-16.564706-48.188236 3.011765-13.552941 9.035294-28.611765 19.57647-39.152941 16.564706-13.552941 34.635294-16.564706 43.670589-13.552941z m-204.8 105.411765l28.611764-118.964706 12.047059-54.211765s1.505882-4.517647 1.505883-6.023529c6.023529 0 18.070588 1.505882 51.2 0h12.047058c25.6 0 46.682353 0 58.729412 15.058823 4.517647 6.023529 6.023529 13.552941 6.02353 21.082353 0 6.023529-1.505882 12.047059-1.505883 16.564706-4.517647 19.576471-15.058824 36.141176-28.611765 46.682353-21.082353 16.564706-49.694118 16.564706-73.788235 16.564706h-3.011765l-3.011764 3.011765c0 1.505882-6.023529 24.094118-6.02353 24.094117s-6.023529 31.623529-7.529411 37.647059c-7.529412-1.505882-19.576471-1.505882-46.682353-1.505882z m10.541176 137.035294c-1.505882 4.517647-3.011765 7.529412-6.023529 10.541176-3.011765 3.011765-7.529412 6.023529-18.070589 6.02353h-18.070588v16.564706c0 4.517647 1.505882 4.517647 1.505883 4.517647s1.505882 1.505882 3.011764 1.505882h6.02353l18.070588-1.505882-9.035294 27.105882h-19.576471c-13.552941 0-24.094118 0-28.611764-3.011765-3.011765-1.505882-4.517647-4.517647-3.011765-9.035294l1.505882-64.752941h31.62353v13.552941h7.529411c3.011765 0 4.517647 0 6.02353-1.505882 1.505882-1.505882 1.505882-1.505882 1.505882-3.011765l3.011765-10.541176h25.6l-3.011765 13.552941z m111.435294 64.752941h-34.635294l3.011765-7.529412h-69.270588l7.529411-22.588235h7.529412l36.141177-121.976471 7.529411-24.094117h34.635294l-3.011764 12.047059s9.035294-6.023529 18.070588-9.035294c7.529412-1.505882 43.670588-3.011765 55.717647-3.011765h37.647059v13.552941c0 3.011765 1.505882 3.011765 6.023529 3.011765h6.02353l-6.02353 24.094117h-19.57647c-18.070588 1.505882-24.094118-6.023529-24.094118-15.058823v-13.552941l-3.011765 12.047058h-12.047058l-36.141177 120.470589h9.035294l-7.529412 24.094117h-10.541176l-3.011765 7.529412z m155.105883-106.917647h-37.647059l-6.02353 19.576471h37.647059l-6.023529 19.57647h-40.658824l-7.529412 9.035294h16.564706l4.517647 25.6c0 3.011765 0 4.517647 1.505883 6.02353 1.505882 1.505882 6.023529 1.505882 9.035294 1.505882h4.517647l-7.529412 25.6h-21.082353c-4.517647 0-6.023529-3.011765-9.035294-4.517647-3.011765-1.505882-6.023529-4.517647-6.023529-9.035294l-4.517647-25.6-18.070589 25.6c-6.023529 7.529412-13.552941 13.552941-27.105882 13.552941h-25.6l7.529412-22.588235h10.541176c3.011765 0 6.023529-1.505882 7.529412-1.505883 1.505882-1.505882 3.011765-1.505882 6.023529-4.517647l27.105883-37.647058h-36.141177l6.02353-21.082353h40.658823l6.02353-19.576471h-40.658824l7.529412-22.588235h112.941176l-12.047058 22.588235z m24.094117-70.776471l-1.505882 1.505883-15.058824 25.6c-4.517647 9.035294-13.552941 15.058824-27.105882 15.058823h-22.588235l7.529411-22.588235h4.517648c3.011765 0 4.517647 0 6.023529-1.505882 1.505882 0 1.505882-1.505882 3.011765-3.011765l7.529411-13.552941c12.047059-18.070588 15.058824-25.6 27.105883-45.176471-1.505882-22.588235-3.011765-30.117647-4.517647-43.670588-1.505882-9.035294-3.011765-18.070588-3.011765-27.105882-1.505882-18.070588-1.505882-15.058824-4.517647-27.105883v-1.505882l1.505882-1.505882c18.070588-1.505882 18.070588-3.011765 37.647059-6.02353l1.505882 1.505883 3.011765 49.694117v3.011765c10.541176-22.588235 10.541176-16.564706 22.588235-45.176471v-1.505882l1.505883-1.505882c16.564706-1.505882 19.576471-3.011765 39.152941-6.02353l1.505882 1.505883c-1.505882 0-75.294118 128-85.835294 149.082352z" fill="#107C84" p-id="2573"></path><path d="M775.062588 579.614118l4.517647-13.552942h-51.2l-4.517647 21.082353c7.529412-4.517647 15.058824-7.529412 22.588236-7.529411h28.611764z m105.411765-159.62353c10.541176-4.517647 18.070588-15.058824 19.576471-27.105882 3.011765-13.552941-1.505882-22.588235-10.541177-27.105882l-25.6-1.505883h-4.517647V368.790588l-12.047059 52.705883v3.011764h6.02353c9.035294 0 19.576471 0 27.105882-4.517647z m-28.611765 266.541177h28.611765l7.529412-27.105883h-28.611765l-7.529412 27.105883z m36.141177-120.470589l-9.035294 30.117648s10.541176-4.517647 16.564705-6.02353c6.023529-1.505882 15.058824-1.505882 15.058824-1.505882l6.023529-22.588236h-28.611764z m-24.094118 76.8s10.541176-6.023529 16.564706-7.529411c6.023529-1.505882 15.058824-3.011765 15.058823-3.011765l7.529412-22.588235h-28.611764l-10.541177 33.129411z" fill="#107C84" p-id="2574"></path></svg> -->
						</div>
						<div class="code">
							<div id="payQrCodeForRent"></div>
						</div>
					</div>
					<div class="code-wrap" v-show="nowSelPayType=='online'&&showSureOnlinePay">
						<div class="lastpay">
							<button @click.stop="lastPay">确认支付</button>
						</div>
					</div>
					<div class="code-wrap" v-show="nowSelPayType=='last'">
						<div class="last-pay-info">
							<span class="tit" style="font-size:16px">余额:</span>
							<span class="val" style="color:#fd8d20" v-if="personData && personData.memberAccount">{{personData.memberAccount.totalAmount}}</span>
						</div>
						<div class="lastpay">
							<button @click.stop="lastPay">确认支付</button>
						</div>
					</div>
				</div>
			</div>
		</div>
        <el-dialog
            title="租赁商品"
            :visible.sync="showRentInfo"
            :close-on-press-escape="false"
			:before-close="handleClose"
            :close-on-click-modal="false"
            :show-close="true"
            width="450px"
            >
			<div class="rent-wrap">
				<div class="tit">押金合计</div>
				<div class="sel-item-wrap">
					<div class="sel-item">
						<div class="sel-cont">
							<div class="cont-item">
								<span class="cont-name"><span style="color:red;">*</span>手机:</span>
								<el-input size="mini" type="text" style="width:calc(100% - 55px)" v-model="rentForm.mobile" />
							</div>
						</div>
					</div>
				</div>
				<div class="rent-list">
					<div class="rent-head">
						<span class="it">商品</span>
						<span class="it">详情</span>
					</div>
					<div class="rent-goods">
						<div class="r-li">
							<span class="it" v-if="nowSelRentGoods">{{nowSelRentGoods.name}}</span>
							<span class="it">数量:1</span>
						</div>
						<div class="r-li">
							<span class="it">押金</span>
							<span class="it">{{nowSelRentRule ? Number(nowSelRentRule.amount).toFixed(2) : "--"}}</span>
						</div>
						<div class="r-li">
							<span class="it">租赁使用费</span>
							<span class="it">{{nowSelRentRule ? nowSelRentRule.ruleName : "--"}}</span>
						</div>
					</div>
				</div>
				<div class="btns">
					<span class="btn submit" @click="sureSelRentInfo">支付押金</span>
				</div>
			</div>
            <!-- <span slot="footer" class="dialog-footer">
                <el-button @click="cancelRentInfo">取 消</el-button>
                <el-button type="primary" @click="sureSelRentInfo">确 定</el-button>
            </span> -->
        </el-dialog>
        <!--  -->
		<el-dialog
		title="我的租赁"
		:visible.sync="showMyRentInfo"
		:before-close="handleCloseForRentInfo"
		:close-on-press-escape="false"
		:close-on-click-modal="false"
		:show-close="true"
		width="850px"
		>
			<div style="padding:20px 0;">
				<el-table
				:header-cell-style="{backgroundColor:'#e66a6a',border:'none',color:'#fff'}"
				:data="myRentData"
				border
				style="width: 100%">
				<el-table-column
				prop="productName"
				label="商品名称"
				>
				</el-table-column>
				<el-table-column prop="name" label="数量">
					<span>1</span>
				</el-table-column>
				<el-table-column prop="ruleName" label="租赁使用费">
				</el-table-column>
				<el-table-column label="已租赁时长">
					<template slot-scope="scope">
						<span class="rentTime">{{ spanTime(scope.row.addTime,new Date().getTime()) }}</span>
					</template>
				</el-table-column>
				<el-table-column label="押金金额">
					<template slot-scope="scope">
						<span class="rentPrice">{{ Number(scope.row.totalAmount).toFixed(2) }}</span>
					</template>
				</el-table-column>
				<el-table-column label="实时金额">
					<template slot-scope="scope">
						<span class="rentPrice">{{ Number(scope.row.payAmount).toFixed(2) }}</span>
					</template>
				</el-table-column>
				<el-table-column label="状态">
					<template slot-scope="scope">
						<span class="statusTag" :class="{refund:scope.row.status=='REFUNDED'}">{{ statusFormat[scope.row.status] }}</span>
					</template>
				</el-table-column>
			</el-table>
			</div>
		</el-dialog>
	</div>
</template>

<script>
import imgUrl from '../../router/imgUrl.js';
import {API_BASE_URL,BASE_WS_URL} from "./../../urlConfig/index";
export default {
	props:['storeId','tableNo'],
  	data(){
		return{
			memberEnabled:false,
			rentTimer:null,
			showMyRentInfo:false,
			statusFormat:{
				UNFINISHED:"租赁中",
				FINISHED:"租赁中",
				REFUNDED:"已归还",
			},
			myRentData:[],
			rentTimer:null,
			showPayCodeBoxForRent:false,
            nowSelRentGoodsRules:[],
            nowSelRentGoods:null,
			nowSelRentRule:null,
            rentForm:{
                name:"",
                mobile:"",
                empId:"",
                empName:"",
                ruleId:"",
                productId:"",
                areaId:"",
                numName:"",
                numId:"",
                source:"WEB"
            },
            tables:[],
            areas:[],
            showRentInfo:false,
            leaseProductEnabled:false,
            rentCates:[],
			// 
			curSelCouponId:[],
			orderOverTime:60,
			showOrderLoading:false,
			// 
            showSelCoupon: false, // 选择优惠券弹框
            nowSelCouponItem:{},
			couponType: {
                'GET_ITEM_FREE': '商品抵用券',
                "REDUCE": "代金券"
            },
            curCouponIdx: 0, // 当前选中优惠券索引
            curBindCoupon: [], // 当前已经绑定了的优惠券列表
            curCouponData: {}, // 当前选择优惠券
			// 
			phoneCode:"",
			btnInfo:"获取验证码",
			canGetCode:true,
			// 
			imgStaticUrl:"",
			searchGoods:[],
			showSelEmp:false,
			nowSelEmp:undefined,
			emps:[],
			nowReduceItem:null,
            nowSelNeedSpecItem:null,
            nowSelSpec:[],
            specs:[],
            fromSelSpec:false,
            showSelSpec:false,
            // 
			showPeiGoods:false,
			nowType:"",
            canClick:true,//用于处理快速点击
			customPrice:'',//自定义网费
			customPriceBtn: false,//自定义网费btn
			goodsData: [], // 商品数据
			curSelGoodsData: [], // 当前选择商品
			curTypeIdx: 1,
			curSmallTypeIdx: -1, // 当前选择小类
			imgUrl: imgUrl,
			orderId: '', // 订单id
			storeInfo: {}, // 店铺信息
			choiceArr: [], // 选择商品列表
			couponList: [], // 优惠券列表
			goodSearch: '', // 商品检索关键字
			goodSearchList: [], // 商品检索数组
			showCarDetail: false, // 是否显示购物车
			showOrderDetail: false, // 是否显示订单详情
			showBalance: false, // 显示结算界面
			showCode: false, // 显示支付二维码
			showVipCheckMask: false, // 显示vip二维码框
			showPaySuccess: false, // 支付成功
			showLoding: false, // 用户安全登录
			showVipPayCode: false, // 会员支付二维码
			showDelConfirm: false, // 确认取消支付框
			showOfficialAccountsCode: false, // 显示公众号二维码界面
			payBtn: true, // 控制支付二维码
			personData: '', // 用户数据
			personTimer: '', // 用户数据定时器
			payImgUrl: '', // 支付二维码
			totalPrice: {
			    count: 0, // 总数量
			    total: 0, // 总计金额
			    discount: 0, // 优惠金额
			    amount: 0, // 最终价格
			},
			addGoodBtn: true, // 控制添加商品
			reduceGoodBtn: true, // 控制减少商品
			curVipPerson: {},
			keywords: '',
			identifyingCode: '',
			phone: '', // 手机号
			goodLength: 0, // 商品数量
			oldAmountPrice: 0,

			curCouponPage: 0,
			couponPageSize: 990,

			cancelPaymentApi: true, // 控制取消支付接口

			newOrderStatus: { // 判断需要生成新订单的状态
			    UNFINISHED:1,
			    FINISHED:1,
			    CANCELED:1,
			    REFUNDED:1,
			    FAIL: 1,
			},
			statusType: { // 状态类型
				UNSETTLED: "未结算",
				UNFINISHED: "未处理",
				FINISHED: "已处理",
				CANCELED: "已取消",
				REFUNDED: "已退",
				FAIL: "失败",
				NOTSURE: "支付中"
			},
			goodAnimateLeft: 1000,
			orderPage: 0, // 订单列表当前页码
			orderSize: 4, // 订单列表每页数量
			orderList: [], // 订单列表
			notes:'',//备注
			cashierPayBtn:true,//控制固定二维码支付控制器
			cashierPayType:'',//控制固定二维码支付 微信/支付宝
			payMode:'',//支付方式

			noticeNuber:true,
			isSelectCustomGoods:false,//是否选择自定义商品，用以判断自定义商品数量是否应该加1
			selItem:null,//当前选择的商品
			nowSelNeedPeiItem:null,
			nowSelPeiGoodsIds:[],
			nowSelPeiGoods:[],
			peiGoods:[],
			showPeiGoods:false,
			baseURL:window.baseURL,
			inpPhone:"",
			nowSelPayType:"online",
			showSureOnlinePay:false,
		}
	},
	watch:{
	   	//搜索获取商品
	    goodSearch ( val ) {
	        if ( !(val.replace(/\s/g,'')) ) {
	            this.goodSearchList = [];
	            return;
	        }
	        this.$http.get('products/search?storeId='+this.storeId+'&q='+encodeURI(val)).then((res)=>{
	            this.goodSearchList = res.data;
	        })
		},
		keywords(val){
			if ( !(val.replace(/\s/g,'')) ) {
				this.curSelGoodsData = this.goodsData[this.curTypeIdx];
	            return;
	        }
			if(this.searchGoods && Array.isArray(this.searchGoods)){
				let res = this.searchGoods.filter(it=>{
					if(it.name.indexOf(val)!=-1 || it.name.toLowerCase().indexOf(val)!=-1){
						return true;
					}
				})
				console.log(res)
				this.curSelGoodsData = {products:res};
				this.$forceUpdate();
			}
		},
		showBalance(val){
			if(!val){
				this.nowSelPayType = "online";
			}
		}
	},
	methods: {
		handleClose(){
			this.cancelRentInfo();
		},
		closeBalanceForRent(){
			this.showPayCodeBoxForRent = false;
			if(this.rentTimer){
				clearInterval(this.rentTimer);
			}
			this.cancelRentInfo();
		},
		changeArea(e){
            console.log(e);
            if(this.areas && Array.isArray(this.areas)){
                this.areas.forEach(it=>{
                    if(it.id == e){
                        this.tables = it.nums;
                        this.rentForm.numId = "";
                        this.rentForm.numName = "";
                    }
                })
            }
            this.$forceUpdate();
        },
        changeTable(e){
            if(this.tables && Array.isArray(this.tables)){
                this.tables.forEach(it=>{
                    if(it.id == e){
                        this.rentForm.numName = it.name;
                    }
                })
            }
            this.$forceUpdate();
        },
		cancelRentInfo(){
            this.rentForm = {
                name:"",
                mobile:"",
                empId:"",
                empName:"",
                ruleId:"",
                productId:"",
                areaId:"",
                tableNo:"",
                numId:"",
                source:"WEB"
            }
            this.showRentInfo = false;
            this.nowSelRentRule = null;
			this.getRegionList();
        },
        sureSelRentInfo(){
            console.log(this.rentForm);
            if(!this.rentForm.numId){
                this.$message({
                    message: '机位信息不正确，请联系服务员进行租赁。',
                    showClose: true,
                    type: 'error'
                });
                return;
            }
            if(!this.rentForm.mobile){
                this.$message({
                    message: '请填写手机号',
                    showClose: true,
                    type: 'error'
                });
                return;
            }
            if ( !(/^1[3|4|5|6|7|8|9][0-9]{9}$/.test(this.rentForm.mobile)) ) {
                this.$message.error({
                    message: "请输入正确的手机号",
                    type: 'error'
                });
                return;
            }
            if(!this.rentForm.ruleId){
                this.$message({
                    message: '计费规则配置错误，请联系服务员进行租赁。',
                    showClose: true,
                    type: 'error'
                });
                return;
            }else{
                this.nowSelRentGoodsRules.forEach(it=>{
                    if(it.ruleId == this.rentForm.ruleId){
						if(it.amount){
                            this.rentForm.authCode = undefined;
							this.confirmPaymentForRent('code');
                            this.$forceUpdate();
                        }else{
                            this.rentForm.authCode = undefined;
                            this.confirmPaymentForRent('pay');
                        }
						
						this.$forceUpdate();
                    }
                })
            }
        },
		getOrderDetail(id){
			this.$http({
                url:`${API_BASE_URL}v1/call/order/detail`,
                method:"POST",
                data:{
					id
                }
            }).then(res=>{
				if(res.data.status && (res.data.status=="FINISHED" || res.data.status=="UNFINISHED")){
					this.$message({
						message: '租赁成功',
						showClose: true,
						type: 'success'
					});
					this.closeBalanceForRent();
				}
			})
		},
        confirmPaymentForRent(type){
            // if(!this.rentForm.authCode){
            //     return;
            // }
            if(!this.canClick){
                return;
            }
            this.canClick = false;
            this.$http({
                url:`${API_BASE_URL}v1/call/create/lease/order`,
                method:"POST",
                data:{
                    ...this.rentForm,
                    storeId:this.storeId,
                }
            }).then(res=>{
                // this.showPayLoding = true;
				if(type == "code"){
					this.showPayCodeBoxForRent = true;
					if(res.data && res.data.qeResult && res.data.qeResult.hasOwnProperty("codeImgURL")){
						setTimeout(()=>{
							$('#payQrCodeForRent')[0].innerHTML='';
							let qrcode = new QRCode("payQrCodeForRent", {
								text: res.data.qeResult.codeImgURL,
								colorDark : "#000000",
								colorLight : "#ffffff",
								height: 200,
								width: 200,
								correctLevel : QRCode.CorrectLevel.H
							});
						},200);
						this.rentTimer =  setInterval(()=>{
							this.getOrderDetail(res.data.leaseProductOrder.id);
						},1000)
					}
				}else{
					this.$message({
						message: '租赁成功',
						showClose: true,
						type: 'success'
					});
				}
                this.cancelRentInfo();
                setTimeout(()=>{
                    this.canClick = true;
                },500);
            }).catch(err=>{
                this.cancelRentInfo();
                this.showPayCodeBoxForRent = false;
                setTimeout(()=>{
                    this.canClick = true;
                },500);
            })
        },
		// 
		reCreateOrder(){
			if(this.orderOverTime>0){
				this.$message({
					message: '订单支付中...',
					showClose: true,
					type: 'error'
				});
				return;
			}
			sessionStorage.removeItem("orderId");
			window.location.reload();
		},
		connect(topicId){
			if(this.intervalTimer){
				this.orderOverTime = 60;
				clearInterval(this.intervalTimer);
			}
			let b = new Base64();
    		let authStr = 'Basic '+ b.encode("13980547109"+':'+"123456");
            let socket = new SockJS(BASE_WS_URL+'gs-guide-websocket');
			this.stompClient = Stomp.over(socket);
			let that = this;
			this.stompClient.connect({'Auth-Token':authStr},  (frame)=> {
			// this.stompClient.connect({}, function (frame) {
				that.stompClient.ws.onerror = function (evnt) {
					that.connect();
				};
				that.stompClient.ws.onclose = function (evnt) {
					that.connect();
				};
				that.stompClient.subscribe("/message/" + topicId,  (event)=> {
					let res = JSON.parse(event.body);
					console.log(res);
					if(res.source == "SCAN"){
						this.showBalance = false;
						this.showCarDetail = false;
						this.showOrderLoading = true;
						// 
						let overTimeNum = 0;
						this.intervalTimer = setInterval(()=>{
							overTimeNum += 1;
							this.orderOverTime--;
							if ( overTimeNum >= 60 ) { // 
								this.cancelPayment();
								return;
							}
							this.$http.get(API_BASE_URL+'v1/pay/scan-code/query?orderId='+topicId).then((res)=>{
								if ( res.status === 200 ) {
									this.showOrderLoading = false;
									this.overTimeNum = 0;
									this.getGoods();
									clearInterval(this.intervalTimer);
									this.oldAmountPrice = this.totalPrice.amount;
									this.goodLength = 0;
									this.showCode = false;
									this.showCarDetail = false;
									this.showBalance = false;
									this.showPaySuccess = true;
									this.createOrder();
									this.refreshVipData( this.personData.id );
								}
							}).catch(()=>{
								clearInterval(this.intervalTimer);
								this.showCode = false;
								setTimeout(()=>{
									this.refresh();
								},3000)
							})
						}, 1000)
						// 
					}
				});
			});
			this.stompClient.ws.onclose = function (evnt) {
				setTimeout(() => {
					that.connect();
				}, 1000);
			};
			this.stompClient.debug = function (str) {
				console.log(str);
			};
		},
		recallPayStatus(){
			let overTimeNum = 0;
			this.intervalTimer = setInterval(()=>{
				overTimeNum += 2;
				if ( overTimeNum >= 180 ) { // 超过180秒，取消订单
					this.cancelPayment();
					return;
				}
				this.$http.get(API_BASE_URL+'v1/pay/scan-code/query?orderId='+this.orderId).then((res)=>{
					if ( res.status === 200 ) {
						this.getGoods();
						clearInterval(this.intervalTimer);
						this.oldAmountPrice = this.totalPrice.amount;
						this.goodLength = 0;
						this.showCode = false;
						this.showCarDetail = false;
						this.showBalance = false;
						this.showPaySuccess = true;
						this.createOrder();
						this.refreshVipData( this.personData.id );
					}
				}).catch(()=>{
					clearInterval(this.intervalTimer);
					this.showCode = false;
				})
			}, 2000)
		},
		// 
		returnOrderStatus(orderId,reGetCode=false){
			this.$http({
				url:`orders/${orderId}/cancelPay`,
				method:"POST"
			}).then(res=>{
				if(this.intervalTimer){
					clearInterval(this.intervalTimer);
				}
				if(reGetCode){
					this.payBtn = true;
					this.reGetCode(false);
				}
			}).catch(err=>{
				console.log(err);
			})
		},
		closeBalance(){
			this.showBalance = false;
			if(this.orderId){
				this.returnOrderStatus(this.orderId);
			}
		},
		// 
		lastPay(){
			console.log(this.curSelCouponId);
			if(this.totalPrice.amount > this.personData.memberAccount.totalAmount){
				this.$message({
					message: '会员余额不足，请先联系服务员进行会员充值!',
					showClose: true,
					type: 'error'
				});
				return;
			}
			let deliveryParams = {};
			if(this.storeInfo.deliveryEnabled){
				if(this.nowSelEmp){
					if(this.emps && Array.isArray(this.emps) && this.emps.length){
						this.emps.forEach(it=>{
							if(it.id == this.nowSelEmp){
								deliveryParams = {
									mobile:it.mobile,
									name:it.name,
								}
							}
						})
					}
				}else{
					if(this.emps && Array.isArray(this.emps) && this.emps.length){
						this.$message({
							message: '请选择配送人员！',
							type: 'error'
						})
						this.payBtn = true;
						return;
					}
				}
			}
			let data = {
				"orderId": this.orderId,
                "channel": "MEMBER",
				"authCode":"",
                "amount": (this.totalPrice.amount).toFixed(2),
                "tableNo": this.tableNo,
                "notes": this.notes,
                "coupon":this.curSelCouponId,
				...deliveryParams
			}
			if ( !this.cashierPayBtn ) {
		        return;
		    }
		    this.cashierPayBtn = false;
			this.$http.put('payments/' + this.$uuid(), data).then((res)=>{
				this.showCode=false;
				this.showBalance=false;
				this.showCarDetail=false;
				this.cashierPayBtn = true;
				this.createOrder();
				this.$message({
		        	message: '支付成功！',
		        	type: 'success'
		        });
				this.showPaySuccess = true;
			}).catch(()=>{
				this.cashierPayBtn = true;
			})
		},
		// 
		changePayType(type){
			if(type=="last"){
				if(!this.personData || !this.personData.memberAccount){
					 this.$message({
                        message: '请先绑定优惠',
                        showClose: true,
                        type: 'error'
                    });
					return;
				}
			}
			this.nowSelPayType = type;
		},
		// 打开选择优惠券弹框
        openCoupon: function () {
            this.showPayLoding = true;
            console.log("choiceArr",this.choiceArr)//
            let choiceArrIds = [];
            if(this.choiceArr && Array.isArray(this.choiceArr) && this.choiceArr.length){
                this.choiceArr.forEach(it=>{
                    choiceArrIds.push(it.productId);
                })       
            }
            this.$http.get(this.personData.id+'/coupon-instance?storeId='+this.storeId+'&page='+this.curCouponPage+'&size='+this.couponPageSize).then((res)=>{
                this.showPayLoding = false;
                if(res.data.couponInstances && Array.isArray(res.data.couponInstances) && res.data.couponInstances.length){
                    res.data.couponInstances.forEach(it=>{
                        let products = [];
                        if(it.productId){
                            let productIds = it.productId.split(",");
                            let productNames = it.productName.split(",");
                            if(productIds && Array.isArray(productIds) && productIds.length){
                                productIds.forEach((ite,ind)=>{
                                    if(choiceArrIds.indexOf(ite)!=-1){
                                        let obj = {
                                            productId:ite,
                                            productName:productNames[ind]
                                        }
                                        products.push(obj);
                                    }
                                })
                            }
                        }
                        
                        it.products = products;
                    })
                }
                console.log("res.data.couponInstances",res.data.couponInstances)
                this.couponList = res.data.couponInstances;
                if ( this.couponList && this.couponList[0] ) {
                    this.showSelCoupon = true;
                    // this.curCouponData = this.couponList[0];
                    this.curCouponIdx = -1;
                } else {
                    this.$message({
                        message: '暂无可用优惠券',
                        showClose: true,
                        type: 'error'
                    });
                }
            }).catch((err)=>{
                console.log("err",err)
                this.showPayLoding = false;
            })
        },
        selCouponItem(item,idx){
            this.curCouponData=item;
            this.curCouponIdx=idx;
            this.nowSelCouponItem = {};
            if(Array.isArray(item.products) && item.products.length==1){
                this.nowSelCouponItem = item.products[0];
            }
        },
        // 
        handleCommand(d){
            this.nowSelCouponItem = d;
        },
        // 选择优惠券
        choiceCoupon: function () {
            if(!this.orderId){
                this.$message({
                    message: '请先选择商品！',
                    showClose: true,
                    type: 'error'
                });
                return
            }
            if(this.curBindCoupon.length){
                this.$message({
                    message: '当前已经绑定优惠券。',
                    showClose: true,
                    type: 'error'
                });
                return;
            }
            
            let productId = "";
			try {
				if(this.curCouponData.products && Array.isArray(this.curCouponData.products) && this.curCouponData.products.length > 1){
					if(!this.nowSelCouponItem || !this.nowSelCouponItem.productName){
						this.$message({
							message: '请选择优惠券所需抵扣的商品',
							showClose: true,
							type: 'error'
						});
						return;
					}else{
						productId = this.nowSelCouponItem.productId;
					}
				}else{
					let ids = this.curCouponData.productId.split(",")
					if(ids.length > 1){
						productId = this.curCouponData.products[0].productId;
					}else{
						productId = this.curCouponData.productId;
					}
				}
			} catch (error) {
                this.$message.error("优惠券选择有误，无对应商品优惠。");
				return;
			}

			if(!productId){
                this.$message.error("优惠券选择有误，无对应商品优惠。");
				return;
			}
            

            if(!this.canClick){
                return;
            }
            this.canClick = false;
			this.returnOrderStatus(this.orderId);
			setTimeout(()=>{
				this.$http.put('orders/'+this.orderId+'/attachCouponInstance?couponInstanceCode='+this.curCouponData.code+"&productId="+productId).then((res)=>{
					
					this.curBindCoupon = res.data.couponInstances;
					this.showSelCoupon = false;

					let body = res.data;
					let items = body.items;
					let discountOrderItem = res.data.discountOrderItem;
							
					for(let i=0;i<items.length;i++){
						items[i].isDiscountForSecond = false;
						for(let j=0;j<discountOrderItem.length;j++){
							if(items[i].id == discountOrderItem[j].orderItem.id){
								items[i].discountForSecondQty = discountOrderItem[j].qty;
								items[i].isDiscountForSecond = true;
							}
						}
					}

					this.choiceArr = items;

					this.totalPrice = {
						count:    res.data.count, // 总数量
						total:    res.data.total, // 总计金额
						discount: res.data.discount, // 优惠金额
						amount:   res.data.amount, // 最终价格
						removeZero:   res.data.removeZero, // 最终价格
					}
					this.$message({
						message: '成功绑定优惠券',
						showClose: true,
						type: 'success'
					});
					try {
						let curSelCouponIdObj = {};
						curSelCouponIdObj.couponInstanceCode = this.curCouponData.code;
						this.curSelCouponId.push(curSelCouponIdObj);
					// 存入session
						sessionStorage.setItem("nowCurBindCoupon",JSON.stringify(this.curBindCoupon));
						sessionStorage.setItem("nowSelCouponItem",JSON.stringify(this.nowSelCouponItem));
					} catch (error) {
						console.log(error)
					}
					if(res.data.amount == 0){
						this.showSureOnlinePay = true;
						return;
					}
					// 
					setTimeout(()=>{
						this.canClick = true;
					},500);
					this.reGetCode(false);

				}).catch(()=>{
					setTimeout(()=>{
						this.canClick = true;
					},500);
				})
			},1000)
            
        },
        // 解除优惠券
        relieveCoupon: function ( item ) {
            let productId = "";
            let nowSelCouponItem = sessionStorage.getItem("nowSelCouponItem") ? JSON.parse(sessionStorage.getItem("nowSelCouponItem")) : null;
            if(nowSelCouponItem && nowSelCouponItem.productId){
                productId = nowSelCouponItem.productId
            }else{
                productId = item.productId;
            }
			this.returnOrderStatus(this.orderId);
			setTimeout(()=>{
            this.$http.put('orders/'+this.orderId+'/relieveCouponInstance?couponInstanceCode='+item.couponInstanceCode+"&productId="+productId).then((res)=>{
				// 
				this.showSureOnlinePay = false;
				this.reGetCode(false);
				// 
				this.nowSelCouponItem = {};
                this.curBindCoupon = res.data.couponInstances;
                let body = res.data;
                let items = body.items;
                let discountOrderItem = res.data.discountOrderItem;
                        
                for(let i=0;i<items.length;i++){
                    items[i].isDiscountForSecond = false;
                    for(let j=0;j<discountOrderItem.length;j++){
                        if(items[i].id == discountOrderItem[j].orderItem.id){
                            items[i].discountForSecondQty = discountOrderItem[j].qty;
                            items[i].isDiscountForSecond = true;
                        }
                    }
                }

                this.choiceArr = items;
                this.totalPrice = {
                    count:    res.data.count, // 总数量
                    total:    res.data.total, // 总计金额
                    discount: res.data.discount, // 优惠金额
                    amount:   res.data.amount, // 最终价格
                    removeZero:   res.data.removeZero, // 最终价格
                }
                console.log(item);
                let index;
                for(let i=0;i<this.curSelCouponId.length;i++){
                    let couponCode = this.curSelCouponId[i].couponInstanceCode;
                    if(couponCode === item.couponInstanceCode){
                        index = i;
                    }
                }
                if(index > -1){
                    this.curSelCouponId.splice(index,1);
                }
                console.log(index)
                sessionStorage.removeItem("nowSelCouponItem");
                console.log(this.curSelCouponId);
				this.canClick = true;
            }).catch((err)=>{
                console.log("ERR",err);
                console.log(this.curSelCouponId);
				this.nowSelCouponItem = {};
				this.canClick = true;
            })
			this.$forceUpdate();
			},1000)
        },
		// 
		memberLogin(){
			if(!this.inpPhone){
				this.$message.error("请正确输入手机号");
				return;
			}
			if(!(/^1[3456789]\d{9}$/.test(this.inpPhone))){
				this.$message.error("请正确输入手机号");
				return;
			}
			if(!this.phoneCode){
				this.$message.error("请正确输入验证码");
				return;
			}
			this.$http({
				url:"member/mobile",
				method:"GET",
				params:{
					mobile:this.inpPhone,
					storeId:this.storeId,
					orderId:this.orderId,
					code:this.phoneCode
				}
			}).then(res=>{
				this.returnOrderStatus(this.orderId,true);
				this.showLoding = false;
				// this.showBalance = false;
				this.personData = res.data;

				this.choiceArr = res.data.order.items;
				this.totalPrice = {
					count: res.data.order.count, // 总数量
					total: res.data.order.total, // 总计金额
					discount: res.data.order.discount, // 优惠金额
					amount: res.data.order.amount, // 最终价格
				}
				sessionStorage.setItem('personData', JSON.stringify(this.personData));
				this.openCoupon();
			})
		},
		getCode(){
			if(!this.inpPhone){
				this.$message.error("请正确输入手机号");
				return;
			}
			if(!(/^1[3456789]\d{9}$/.test(this.inpPhone))){
				this.$message.error("请正确输入手机号");
				return;
			}
			if (this.btnInfo != "获取验证码") {
				this.$message.error("请正确输入手机号");
				return;
			}
			if(!this.canGetCode){
				return;
			}
			this.$http({
				url:"member/mobile/code",
				method:"GET",
				params:{
					mobile:this.inpPhone,
					storeId:this.storeId
				}
			}).then(res=>{
				this.canGetCode = false;
				let sec = 60;
				this.timer = setInterval(() => {
				sec--;
				this.btnInfo = sec + "s";
				if (sec == 0) {
					this.btnInfo = "获取验证码";
					this.canGetCode = true;
					clearInterval(this.timer);
				}
				}, 1000);
			})
		},
		// 
		doShowEmp(){
			this.getEmps(true);
		},
		beforeSelGoodsWithImg(item){
			let ref = this.$refs[item.id];
			this.beforeSelGoods({target:ref},item);
		},
		// 
		querySearchAsync(queryString,cb){
			if(!String(queryString).trim()){
				cb([])
				return;
			}
			if(this.searchGoods && Array.isArray(this.searchGoods)){
				let res = this.searchGoods.filter(it=>{
					if(it.name.indexOf(queryString)!=-1){
						return true;
					}
				})
				console.log(res);
				cb(res);
			}else{
				cb([]);
			}
		},
		beforeSelSearchGoods(event,e){
			this.keywords = "";
			console.log(this.$refs.searchWrap);
			if(e && e.id){
				if(!e.purchaseEnabled){
					this.$message.error("请呼叫购买");
					return;
				}
				this.beforeSelGoods({target:this.$refs.searchWrap},e);
			}
		},
		// 
		toSelEmp(it){
			this.$http({
				url:`${this.baseURL}v1/pay/emp/work`,
				method:"GET",
				params:{
					empId:it.id
				}
			}).then(res=>{
				this.nowSelEmp = it.id;
				this.showSelEmp = false;
				this.goBalance();
			}).catch(err=>{
				console.log(err)
			})
			
		},
		beforeCloseSpec(){
            this.nowSelNeedSpecItem = null;
            this.nowSelSpec = [];
            this.fromSelSpec = false;
            this.showSelSpec = false;
        },
		modifySpecs(type,it,item){
            item.seledSpec = it;
            console.log(this.specs);
            let nowSelSpec = [];
            if(this.specs && Array.isArray(this.specs) && this.specs.length){
                this.specs.forEach(it=>{
                    if(it.seledSpec){
                        nowSelSpec.push(it.seledSpec);
                    }
                })
            }
            console.log(nowSelSpec)
            this.nowSelSpec = nowSelSpec;
			this.$forceUpdate();
        },
        submitSelSpec(event){
            if(!this.nowSelSpec || !this.nowSelSpec.length ){
                this.$message({
                    message: "请选择规格",
                    showClose: true,
                    type: 'error'
                });
                return;
            }
            console.log(this.nowSelSpec);
            if(this.nowSelSpec.length!=this.specs.length){
                this.$message({
                    message: "请完整选择规格",
                    showClose: true,
                    type: 'error'
                });
                return;
            }
            // 
            this.fromSelSpec = true;
            this.addProduct(event, this.nowSelNeedSpecItem.id,false);
            // 
        },
        //
		beforeAddCount(event,item){
			if(item.productSpecs && Array.isArray(item.productSpecs) && item.productSpecs.length){
                this.nowSelSpec = item.specs;
            	this.fromSelSpec = true;
                // if(item.specs && Array.isArray(item.specs)){
                //     item.productSpecs.forEach(it=>{
                //         it.specs.forEach(ite=>{
                //             if(item.specs.indexOf(ite)!=-1){
                //                 it.seledSpec = ite;
                //             }
                //         })
                //     })
                // }
                // this.specs = item.productSpecs;
                // this.nowSelNeedSpecItem = item;
                // item.id = item.productId;
                // item.name = item.productName;
                // this.showSelSpec = true;
                // return;
            }  
			this.addProduct( event, item.productId, false);
			this.changeNowSelectCount(item,false,'add')
		},
		beforeSelGoods(event,item){
		// 
			if(item.hasOwnProperty("leaseEnabled") && item.leaseEnabled){
				this.showRentInfo = true;
				if(item.extras && Array.isArray(item.extras) && item.extras.length){
					item.extras.forEach((it,ind)=>{
						if(typeof it == "string"){
							item.extras[ind] = JSON.parse(it);
						}
					})
					this.nowSelRentGoodsRules = item.extras;
					console.log("this.nowSelRentGoodsRules",this.nowSelRentGoodsRules)
					this.nowSelRentGoodsRules.forEach((it,ind)=>{
						if(it.defaultPcRule){
							this.rentForm.ruleId = it.ruleId;
							this.nowSelRentRule  = it;
						}
					})
				}
				console.log(item);
				this.nowSelRentGoods = item;
				this.rentForm.productId = item.id;
				// 
				if(this.storeInfo){
					// this.rentForm.empId = this.storeInfo.employeeId;
					// this.rentForm.empName = this.storeInfo.employeeName;
				}
				return;
			}
			// 
			if(item.stockEnabled&&!item.quantity){
				this.$message({
		        	message: '无货',
		        	type: 'error'
		        });
				return;
			}
			if(item.productSpecs && Array.isArray(item.productSpecs) && item.productSpecs.length){
                let resetFlag = true;
                let seledItem = null;
                if(this.choiceArr && Array.isArray(this.choiceArr) && this.choiceArr.length){
                    this.choiceArr.forEach(it=>{
                        if(it.productId == item.id){
                            resetFlag = false;
                            seledItem = it;
                        }
                    })
                }
                if(item.productSpecs && Array.isArray(item.productSpecs)){
                    if(resetFlag){
                        let nowSelSpec = [];
                        item.productSpecs.forEach(it=>{
                            it.seledSpec = it.defaultSpec;
                            nowSelSpec.push(it.defaultSpec);
                        })
                        this.nowSelSpec = nowSelSpec;
                    }else{
                        if(seledItem && seledItem.specs && Array.isArray(seledItem.specs)){
                            item.productSpecs.forEach(it=>{
                                if(it.specs && Array.isArray(it.specs)){
                                    it.specs.forEach(ite=>{
                                        if(seledItem.specs.indexOf(ite)!=-1){
                                            it.seledSpec = ite;
                                        }
                                    })
                                }
                            })
                          this.nowSelSpec = seledItem.specs;
                        }
                    }
                }
                this.specs = item.productSpecs;
                this.nowSelNeedSpecItem = item;
                this.showSelSpec = true;
                return
            }
			if(this.doShowSupply(item.supplyTimes)){
				console.log('当前商品不供应kkk')
				this.$message({
		        	message: '当前商品不供应',
		        	type: 'error'
		        });
				return;
			}
			this.addProduct( event, item.id,false);
			this.changeNowSelectCount(item,false,'add',this.doShowSupply(item.supplyTimes));
		},
		// 
		reduceAmountForPei(it){
            if(!this.canClick){
                return;
            }
            this.canClick = false;
            this.$http({
                url:`orders/${this.orderId}/remove/match`,
                method:"POST",
                data:{
                    orderItemId:it.id,
                    productCount:1
                }
            }).then(res=>{
                this.$message({
                    message: "操作成功",
                    showClose: true,
                    type: 'success'
                });
                // 
                let body = res.data;
                let items = body.items;
                let discountOrderItem = res.data.discountOrderItem;
                for(let i=0;i<items.length;i++){
                    items[i].isDiscountForSecond = false;
                    for(let j=0;j<discountOrderItem.length;j++){
                        if(items[i].productId == discountOrderItem[j].productId){
                            items[i].discountForSecondQty = discountOrderItem[j].qty;
                            items[i].isDiscountForSecond = true;
                        }
                    }
                }
                console.log(items)
                this.choiceArr = items;
                this.totalPrice = {
                    count:    body.count, // 总数量
                    total:    body.total, // 总计金额
                    discount: body.discount, // 优惠金额
                    amount:   body.amount, // 最终价格
                    removeZero:   body.removeZero, // 最终价格
                }
                for (let i = 0, len = this.pageSize - this.choiceArr.length; i < len; i++) {
                    this.choiceArr.push({});
                }
                this.addGoodBtn = true;
                // 
                setTimeout(()=>{
                    this.canClick = true;
                },1000);
                // this.shopUpBoxForReturnMoney(false);
                return;
            }).catch(err=>{
                setTimeout(()=>{
                    this.canClick = true;
                },1000);
            })
        },
		addAmountForPei(item,it){
            if(!this.canClick){
                return;
            }
            this.canClick = false;
            let data = {
                    orderItemId:item.id,
                    orderId:this.orderId,
                    matchParams:[
                        {
                            masterItemId:it.id,
                            productId:it.productId,
                            productCount:1,
                            amount:(it.salesPrice / it.quantity).toFixed(2),
                        }
                    ]
                }
                this.$http({
                    url:`orders/${this.orderId}/add/match`,
                    method:"POST",
                    data
                }).then(res=>{
                    this.showPeiGoods = false;
                    this.$message({
                        message: "操作成功",
                        showClose: true,
                        type: 'success'
                    });
                    // 
                    let body = res.data;
                    let items = body.items;
                    let discountOrderItem = res.data.discountOrderItem;
                    for(let i=0;i<items.length;i++){
                        items[i].isDiscountForSecond = false;
                        for(let j=0;j<discountOrderItem.length;j++){
                            if(items[i].productId == discountOrderItem[j].productId){
                                items[i].discountForSecondQty = discountOrderItem[j].qty;
                                items[i].isDiscountForSecond = true;
                            }
                        }
                    }
                    console.log(items)
                    this.choiceArr = items;
                    this.totalPrice = {
                        count:    body.count, // 总数量
                        total:    body.total, // 总计金额
                        discount: body.discount, // 优惠金额
                        amount:   body.amount, // 最终价格
                        removeZero:   body.removeZero, // 最终价格
                    }
                    for (let i = 0, len = this.pageSize - this.choiceArr.length; i < len; i++) {
                        this.choiceArr.push({});
                    }
                    this.addGoodBtn = true;
                    // 
                    setTimeout(()=>{
                        this.canClick = true;
                    },1000);
                    // this.shopUpBoxForReturnMoney(false);
                }).catch(err=>{
                    setTimeout(()=>{
                        this.canClick = true;
                    },1000);
                })
        },
		modifyPeiGoods(type,item){
            if(type == "add"){
                let nowSelPeiGoods = JSON.parse(JSON.stringify(this.nowSelPeiGoods));
               
                let flag = true;
                let index;
                if(nowSelPeiGoods && Array.isArray(nowSelPeiGoods) && nowSelPeiGoods.length){
                    nowSelPeiGoods.forEach((it,ind)=>{
                        if(it.id == item.id){
                            flag = false;
                            index = ind;
                        }
                    })
                }
                if(flag){
                    nowSelPeiGoods.push(item);
                }else{
                    nowSelPeiGoods.splice(index,1);
                }

                let nowSelPeiGoodsIds = [];
                nowSelPeiGoods.forEach(it=>{
                    nowSelPeiGoodsIds.push(it.id);
                });
                this.nowSelPeiGoods = nowSelPeiGoods;
                this.nowSelPeiGoodsIds = nowSelPeiGoodsIds;
            }
        },
		submitSelPei(){
            if(this.peiGoods && Array.isArray(this.peiGoods) && this.peiGoods.length){
                if(!this.canClick){
                    return;
                }
                this.canClick = false;
                let matchParams = [];
                if(this.nowSelPeiGoods && Array.isArray(this.nowSelPeiGoods) && this.nowSelPeiGoods.length){
                    this.nowSelPeiGoods.forEach(it=>{
                        let obj = {
                            masterItemId:"",
                            productId:it.id,
                            productCount:1,
                            amount:it.salesPrice,
                        }
                        matchParams.push(obj);
                    })
                }
                if(!matchParams.length){
                    this.$message({
                        message: "请选择配品",
                        showClose: true,
                        type: 'error'
                    });
                    this.canClick = true;
                    return;
                }
                let data = {
                    orderItemId:this.nowSelNeedPeiItem.id,
                    orderId:this.orderId,
                    matchParams
                    // masterItemId:"",
                    // productId:this.nowSelPeiGoods.id,
                    // productCount:this.nowSelPeiGoods.selCount,
                    // amount:Number(this.nowSelPeiGoods.selCount)*Number(this.nowSelPeiGoods.salesPrice),
                }
                this.$http({
                    url:`orders/${this.orderId}/add/match`,
                    method:"POST",
                    data
                }).then(res=>{
                    this.showPeiGoods = false;
                    this.$message({
                        message: "操作成功",
                        showClose: true,
                        type: 'success'
                    });
                    let body = res.data;
                    let items = body.items;
                    let discountOrderItem = res.data.discountOrderItem;
                    for(let i=0;i<items.length;i++){
                        items[i].isDiscountForSecond = false;
                        for(let j=0;j<discountOrderItem.length;j++){
                            if(items[i].productId == discountOrderItem[j].productId){
                                items[i].discountForSecondQty = discountOrderItem[j].qty;
                                items[i].isDiscountForSecond = true;
                            }
                        }
                    }
                    console.log(items)
                    this.choiceArr = items;
                    this.totalPrice = {
                        count:    body.count, // 总数量
                        total:    body.total, // 总计金额
                        discount: body.discount, // 优惠金额
                        amount:   body.amount, // 最终价格
                        removeZero:   body.removeZero, // 最终价格
                    }
                    for (let i = 0, len = this.pageSize - this.choiceArr.length; i < len; i++) {
                        this.choiceArr.push({});
                    }
                    this.addGoodBtn = true;
                    setTimeout(()=>{
                        this.canClick = true;
                    },1000);
                    // this.shopUpBoxForReturnMoney(false);
                }).catch(err=>{
                    setTimeout(()=>{
                        this.canClick = true;
                    },1000);
                })
            }
        },
		doShowPeiGoods(item){
            this.nowSelNeedPeiItem = item;
            this.nowSelPeiGoodsIds = [];
            this.nowSelPeiGoods = [];
            if(item.masterItemDtos && Array.isArray(item.masterItemDtos) && item.masterItemDtos.length){
                let nowSelPeiGoodsIds = [];
                let masterItemDtos = JSON.parse(JSON.stringify(item.masterItemDtos));
                let obj = {};
                masterItemDtos.forEach(it=>{
                    obj[it.productId] = it;
                    nowSelPeiGoodsIds.push(it.productId);
                });
                let tempArr = [];
                for(let k in obj){
                    obj[k]["id"] =  obj[k].productId;
                    tempArr.push(obj[k]);
                }
                this.nowSelPeiGoodsIds = nowSelPeiGoodsIds;
                this.nowSelPeiGoods = tempArr;
            }
            this.$http({
                url:"orders/match/product/list",
                method:"POST",
                data:{
                    productId:item.productId
                }
            }).then(res=>{
                if(res.data && Array.isArray(res.data) && res.data.length){
                    res.data.forEach(it=>{
                        it.selCount = 0;
                    })
                    this.peiGoods = res.data;
                    this.showPeiGoods = true;
                }else{
                   this.$message({
                        message: "暂无相关配品，请在后台设置。",
                        showClose: true,
                        type: 'error'
                    });
                    return;
                }
            })
        },
		// 
		//改变商品选择的数量
		//isSupply当前商品是否正在供应
		changeNowSelectCount(item,custom,type,notSupply = false){
			if(!this.canClick){
                return;
            }
			if(notSupply){
				console.log('当前商品不供应')
				return;
			}
			this.selItem = item;
			if(type === 'add'){
				//custom 为自定义控制器
				if ( item.id == '0' && !custom) {
					//如果是自定义商品
					if( this.isSelectCustomGoods ){
						//网费只需要叠加为1
						item.nowSelectCount = 1;
						this.isSelectCustomGoods =false;
					}else{
						this.isSelectCustomGoods =false;
					}
					return;
				}
				item.nowSelectCount==0||item.nowSelectCount?item.nowSelectCount++:Object.assign(item,{nowSelectCount:item.quantity+1});
				// return;
				console.log(item.nowSelectCount)
				// return;
				for(let i=0;i<this.goodsData.length;i++){
				// if(this.goodsData[i].products !== []){
					for(let j=0;j<this.goodsData[i].products.length;j++){
						if(this.goodsData[i].products[j].id === item.productId){
							Object.assign(this.goodsData[i].products[j],{nowSelectCount:item.nowSelectCount});
						}
					}
				// }
				}
			}else if(type === 'del'){
				console.log(item);
				// return;
				for(let i=0;i<this.goodsData.length;i++){
				// if(this.goodsData[i].products !== []){
					for(let j=0;j<this.goodsData[i].products.length;j++){
						if(this.goodsData[i].products[j].id === item.productId){
							Object.assign(this.goodsData[i].products[j],{nowSelectCount:0});
						}
					}
				// }
				}
			}else{
				//custom 为自定义控制器
				if ( item.id == '0' && !custom) {
					//如果是自定义商品
					if( this.isSelectCustomGoods ){
						//网费只需要叠加为1
						item.nowSelectCount = 1;
						this.isSelectCustomGoods =false;
					}else{
						this.isSelectCustomGoods =false;
					}
					return;
				}
				item.nowSelectCount==0||item.nowSelectCount?item.nowSelectCount++:Object.assign(item,{nowSelectCount:item.quantity-1});
				// return;
				console.log(item.nowSelectCount)
				// return;
				for(let i=0;i<this.goodsData.length;i++){
				// if(this.goodsData[i].products !== []){
					for(let j=0;j<this.goodsData[i].products.length;j++){
						if(this.goodsData[i].products[j].id === item.productId){
							Object.assign(this.goodsData[i].products[j],{nowSelectCount:item.nowSelectCount});
						}
					}
				// }
				}
			}
			this.canClick = false;
			setTimeout(()=>{
				this.canClick = true;
			},500);
		},
		doShowSupply(info){
            let date = new Date();
            let nowH = date.getHours();
            let nowM = date.getMinutes();

            console.log('当前时间为:'+nowH+' 分钟数wei:'+nowM);
            let notSupply = true;
            if(info!=='[]'&&info!==null){
                let timeData = JSON.parse(info);
                for(let i=0;i<timeData.length;i++){
                    if(nowH>=timeData[i].beginHour&&nowH<=timeData[i].endHour){
						if(nowH==timeData[i].beginHour&&nowM<timeData[i].beginMinute){
                            notSupply = true;
                            return notSupply;           
                        }
                        if(nowH==timeData[i].endHour&&nowM>timeData[i].endMinute){
                            notSupply = true;
                            return notSupply;           
                        }
                        notSupply = false;
                        return notSupply;
                    }
                }
                return notSupply;
            }else{
                return false;
            }
        },
		//线下支付
		cashierPay(){
			let data = {
                "orderId": this.orderId,
                "channel": "CASH",
                "amount": this.totalPrice.amount,
                "tableNo": this.tableNo,
                "notes": this.notes,
                "coupon":this.curSelCouponId,
            }
            if ( !this.cashierPayBtn ) {
		        return;
		    }
		    this.cashierPayBtn = false;
			let deliveryParams = {};
			if(this.storeInfo.deliveryEnabled){
				if(this.nowSelEmp){
					if(this.emps && Array.isArray(this.emps) && this.emps.length){
						this.emps.forEach(it=>{
							if(it.id == this.nowSelEmp){
								deliveryParams = {
									mobile:it.mobile,
									name:it.name,
								}
							}
						})
					}
				}
			}
			this.$http.put('payments/' + this.$uuid(), {...data,...deliveryParams}).then((res)=>{
				this.showCode=false;
				this.showBalance=false;
				this.showCarDetail=false;
				setTimeout(()=>{
					this.cashierPayBtn = true;
				},500)
				this.createOrder();
				this.$message({
		        	message: '支付成功！',
		        	type: 'success'
		        });
				this.goodLength = 0;
				this.showPaySuccess = true;
			}).catch(()=>{
				setTimeout(()=>{
					this.cashierPayBtn = true;
				},500)
			})
		},
		//订单备注
		orderNotes(){
			let body= {
				notes:this.notes
			}
		 	this.$http.post('orders/'+this.orderId+'/notes',body).then((res)=>{
		 		this.notes = '';
		 	})
		},
		// 选择优惠券
		selCoupon: function ( item ) {
			if ( !item ) {
				this.curBindCoupon = {
					title: "无优惠"
				}
				this.$http.put('orders/'+this.orderId+'/relieveCouponInstance').then((res)=>{
					let body = res.data;
					this.totalPrice = {
					    count: body.count, // 总数量
					    total: body.total, // 总计金额
					    discount: body.discount, // 优惠金额
					    amount: body.amount, // 最终价格
					}
				}).catch(()=>{
					this.getOrderCoupon();
				})
			} else {
				this.curBindCoupon = item;
				this.$http.put('orders/'+this.orderId+'/attachCouponInstance?couponInstanceCode='+this.curBindCoupon.code).then((res)=>{
					let body = res.data;
					this.totalPrice = {
					    count: body.count, // 总数量
					    total: body.total, // 总计金额
					    discount: body.discount, // 优惠金额
					    amount: body.amount, // 最终价格
					}
				}).catch(()=>{
					this.getOrderCoupon();
				})
			}
			$('#couponBox').css('height', 30);
		},
		// 订单跳转页面
		curPageFn(foo){
		    if(this.orderList.totalPages<=1){
		        return;
		    }
		    if(foo==2){
		        if( this.orderPage <= 0 ){
		            return;
		        }
		        this.orderPage--;
		    }else if(foo==1) {
		        if( (this.orderPage+1)>=this.orderList.totalPages ){
		            return;
		        }
		        this.orderPage++;
		    }
		    // this.commissionDetail(false);

		    this.$http.get(this.personData.id+'/orders?page='+this.orderPage+'&size='+this.orderSize).then((res)=>{
		    	this.orderList = res.data;
		    }).catch(( err )=>{

		    })
		},
		isShowGoodsType(data){
			if(data && Array.isArray(data) && data.length){
				data.forEach(it=>{
					if(it.products && Array.isArray(it.products) && it.products.length){
						it.isShow = true;
					}
					if(it.subTypes && Array.isArray(it.subTypes) && it.subTypes.length){
						it.subTypes.forEach(ite=>{
							if(ite.products && Array.isArray(ite.products) && ite.products.length){
								ite.isShow = true;
								it.isShow = true;
							}
						})
					}
				})
			}
		},
		// 获取商品列表
		getGoods: function () {
		    this.$http.get('products?storeId='+this.storeId).then((res)=>{
				this.isShowGoodsType(res.data);
				let data = res.data;
				if(data.length){
					for(let i=0;i<data.length;i++){
						let flag = false;
						if(data[i].products.length){
							for(let j=0;j<data[i].products.length;j++){
								if(data[i].products[j].showEnabled){
									flag = true;
								}
							}
						}
						if(data[i].subTypes.length){
							// 排序
							data[i].subTypes.sort((a,b)=>{
								return a.sequence-b.sequence;
							})
							// 
							for(let x=0;x<data[i].subTypes.length;x++){
								for(let y=0;y<data[i].subTypes[x].products.length;y++){
									Object.assign(data[i].subTypes[x].products[y],{nowSelectCount:0});
									if(data[i].subTypes[x].products[y].showEnabled){
										flag = true;
									}
								}
							}
						}
						data[i].dontShowThisCate = flag;
					}
				}
				console.log(data);
				let tmlData = [];
				if(data && Array.isArray(data) && data.length){
					data.forEach(it=>{
						if(it.dontShowThisCate){
							tmlData.push(it);
						}
					})
				}
				// 
				let rentCates = [];
                let normalCates = [];
                if(tmlData && Array.isArray(tmlData) && tmlData.length){
                    tmlData.forEach((it,ind)=>{
                        if(it.leaseEnabled){
                            if(it.products && Array.isArray(it.products) && it.products.length){
                                it.products.forEach(ite=>{
                                    ite.productStatus = "ON";
                                    ite.leaseEnabled = true;
                                })
                            }
                            rentCates.push(it);
                        }else{
							it.queue=it.sequence;

                            normalCates.push(it);
                        }
                    })
                }
				// 
				this.goodsData = tmlData;
				// if(this.leaseProductEnabled){
				// 	this.goodsData = [normalCates[0],...rentCates,...normalCates.slice(1)];
				// }else{
				// 	this.goodsData = [...normalCates];
				// }
				//
				// this.goodsData.forEach(it=>{
					
				// })
				// this.goodsData = res.data;
				for(let i=0;i<this.goodsData.length;i++){
					// if(this.goodsData[i].products !== []){
						for(let j=0;j<this.goodsData[i].products.length;j++){
							Object.assign(this.goodsData[i].products[j],{nowSelectCount:0});
						}
					// }
				}
		        this.curSelGoodsData = [];

		        setTimeout(()=>{
					// this.curSelGoodsData = this.goodsData[this.curTypeIdx];
					//
					let curSelGoodsData = this.goodsData[this.curTypeIdx];
					this.rollGoods(this.goodsData);
					// let productsData = curSelGoodsData.products;
					// for(let i=0;i<productsData.length;i++){
					// 	Object.assign(productsData[i],{nowSelectCount:0});
					// }
					this.curSelGoodsData = curSelGoodsData;
					// console.log(this.curSelGoodsData)
					//
    		        setTimeout(()=>{
	    		        Echo.init({
	    		            offset: 0,//离可视区域多少像素的图片可以被加载
	    		        　　throttle: 0, //图片延时多少毫秒加载
		    		        scrollDomId: 'scroller',
	    		        });
    		        }, 200)
				}, 100)
		    })
		},

		rollGoods(data){
			if(data && Array.isArray(data) && data.length){
				data.forEach(it=>{
					if(it.products && Array.isArray(it.products) && it.products.length){
						this.searchGoods = this.searchGoods.concat(it.products);
					}
					if(it.subTypes && Array.isArray(it.subTypes) && it.subTypes.length){
						this.rollGoods(it.subTypes);
					}
				})
			}
		},

		// 点击选择商品分类
		selGoodType: function ( idx ) {
			console.log("idx",idx)
			if ( this.curTypeIdx !== idx ) {
				$($('.leftBar li')[idx]).css('height', 'auto');
			} else {
				if ( $($('.leftBar li')[idx]).css('height') == '60px' ) {
					$($('.leftBar li')[idx]).css('height', 'auto');
				} else {
					$($('.leftBar li')[idx]).css('height', '60px');
				}
			}
			this.curSmallTypeIdx = -1;
			this.curTypeIdx = idx;
			this.curSelGoodsData = [];

			setTimeout(()=>{
				this.curSelGoodsData = this.goodsData[idx];
		        setTimeout(()=>{
					Echo.init({
					    offset: 0,//离可视区域多少像素的图片可以被加载
					　　throttle: 0, //图片延时多少毫秒加载
						scrollDomId: 'scroller',
					});
		        }, 200)
			}, 100);
		},
		selSmallGoodType: function ( idx, smallIdx ) {
			this.curTypeIdx = idx;
			this.curSmallTypeIdx = smallIdx;
			this.curSelGoodsData = [];

			setTimeout(()=>{
				this.curSelGoodsData = this.goodsData[idx].subTypes[smallIdx];
		        setTimeout(()=>{
					Echo.init({
					    offset: 0,//离可视区域多少像素的图片可以被加载
					　　throttle: 0, //图片延时多少毫秒加载
						scrollDomId: 'scroller',
					});
		        }, 200)
			}, 100);
		},
		// //呼叫
		// noticeFn(){
		// 	if ( !this.noticeNuber ) {
		// 		this.$message({
		// 			message: '呼叫请勿太频繁!',
		// 			type: 'error'
		// 		})
		//         return;
		//     }
		//     this.noticeNuber = false;
		// 	let body = {
		// 		id:this.$uuid(),
		// 		storeId:this.storeId,
		// 		tableNo:this.tableNo
		// 	};
		// 	this.$http.post('/notice',body).then((res)=>{
		// 		this.$message({
		// 			message: '呼叫成功!',
		// 			type: 'success'
		// 		})
		// 		setTimeout((res)=>{
		// 			this.noticeNuber = true;
		// 			sessionStorage.setItem('NOTICE',true);
		// 		},30000)
		// 	}).catch((err)=>{
		// 		setTimeout((res)=>{
		// 			this.noticeNuber = true;
		// 			sessionStorage.setItem('NOTICE',true);
		// 		},30000)
		// 	})
		// },
		// 回到顶部
		goTop: function () {
			$('#scroller').animate({scrollTop:0},500);
		},
		// 刷新页面
		refresh: function () {
			window.location.reload(true);
		},

		// 生成订单
		createOrder: function () {
		    // this.orderId = this.$uuid();
		    // sessionStorage.setItem('orderId', this.orderId);
		    this.choiceArr = [];
		    this.goodLength = 0;
		    this.notes = '';

			this.curBindCoupon = {
				title: "无优惠"
			}
		    // let url = 'orders/'+ this.orderId + '?storeId=' + this.storeId;
		    // if ( sessionStorage.getItem('personData') ) {
		    // 	this.personData = JSON.parse(sessionStorage.getItem('personData'));
		    // 	url += '&memberId='+this.personData.id;
		    // }

		    // this.$http.put(url).then((res)=>{
		    // 	this.getOrderCoupon();
		    // }).catch(()=>{
		    	sessionStorage.removeItem('orderId');
		    // })
		},

		// 选择搜索出来的商品
		selSearchGood: function ( productId ) {
			if ( !this.addGoodBtn ) {
			    return;
			}
			this.addGoodBtn = false;
			if(sessionStorage.getItem('orderId')){
		    	 //有本地id就赋值 ， 
                this.orderId = sessionStorage.getItem('orderId')
		    }else{
		    	//没有就新建id
                let url='?createTime='+new Date().getTime()+'&storeId='+this.storeId;
                if(JSON.parse(sessionStorage.getItem('personData'))&&JSON.parse(sessionStorage.getItem('personData')).id){
                	this.personData = JSON.parse(sessionStorage.getItem('personData'));
                	url+=('&memberId='+JSON.parse(sessionStorage.getItem('personData')).id)
                }
                this.$http.put('/create-orders'+url).then((res)=>{
                    sessionStorage.setItem('orderId',res.data.id);
                    this.orderId = res.data.id;
                    this.$http.post('orders/' + this.orderId + '/add', {
					    "productId": productId,
					    "productCount": 1,
					}).then((res)=>{
					    let body = res.data;
					    this.choiceArr = body.items;

					    this.goodLength = 0;
					    for (var i = 0, len = this.choiceArr.length; i < len; i++) {
					    	this.goodLength += this.choiceArr[i].quantity;
					    }
					    this.totalPrice = {
					        count: body.count, // 总数量
					        total: body.total, // 总计金额
					        discount: body.discount, // 优惠金额
					        amount: body.amount, // 最终价格
					    }
					    this.addGoodBtn = true;

					    this.$message({
					    	message: '成功',
					    	type: 'success'
					    })

					    this.goodSearchList = [];
					    this.goodSearch = '';
					}).catch((err)=>{
					    this.addGoodBtn = true;
					    if ( err.response.status === 400 ) {
					        this.checkOrderStatus();
					    }
					})
                })
                return;
		    }
			this.$http.post('orders/' + this.orderId + '/add', {
			    "productId": productId,
			    "productCount": 1,
			}).then((res)=>{
			    let body = res.data;
			    this.choiceArr = body.items;

			    this.goodLength = 0;
			    for (var i = 0, len = this.choiceArr.length; i < len; i++) {
			    	this.goodLength += this.choiceArr[i].quantity;
			    }
			    this.totalPrice = {
			        count: body.count, // 总数量
			        total: body.total, // 总计金额
			        discount: body.discount, // 优惠金额
			        amount: body.amount, // 最终价格
			    }
			    this.addGoodBtn = true;

			    this.$message({
			    	message: '成功',
			    	type: 'success'
			    })

			    this.goodSearchList = [];
			    this.goodSearch = '';
			}).catch((err)=>{
			    this.addGoodBtn = true;
			    if ( err.response.status === 400 ) {
			        this.checkOrderStatus();
			    }
			})
		},

		// 添加商品
		addProduct: function ( event, productId ,custom) {
			if(!this.canClick){
                return;
            }
		    if ( !this.addGoodBtn ) {
		        return;
		    }
		    //custom 为自定义控制器
		    if ( productId == '0' && !custom ) {
		    	//如果是自定义商品
		    	this.customPriceBtn = true;
		    	setTimeout(()=>{
		    		$('#inputMoney input').focus();
		    	},100)
		    	return;
		    }
		    let body = {};
		    if( custom ){
			    if( !/^[0-9]*[1-9][0-9]*$/.test(this.customPrice)){
			    	this.$message({
			        	message: '请输入正整数！',
			        	type: 'error'
			        })
			    	return;
			    }
			    if(parseInt(this.customPrice)>=10000){
			    	this.$message({
			        	message: '较大金额请到前台充值！',
			        	type: 'error'
			        })
			    	return;
			    }
			    body = {
			    	"productId": productId,
			    	"amount":parseInt(this.customPrice),
		        	"productCount": 1,
				}
				this.isSelectCustomGoods = true;
		    }else{
		    	body = {
		    		"productId": productId,
		        	"productCount": 1,
                	specs:this.fromSelSpec?this.nowSelSpec:undefined
			    }
		    }

		    this.addGoodBtn = false;
		    if(sessionStorage.getItem('orderId')){
		    	 //有本地id就赋值 ， 
                this.orderId = sessionStorage.getItem('orderId')
		    }else{
		    	//没有就新建id
                let url='?createTime='+new Date().getTime()+'&storeId='+this.storeId;
                if(JSON.parse(sessionStorage.getItem('personData'))&&JSON.parse(sessionStorage.getItem('personData')).id){
                	this.personData = JSON.parse(sessionStorage.getItem('personData'));
                	url+=('&memberId='+JSON.parse(sessionStorage.getItem('personData')).id)
                }
                this.$http.put('/create-orders'+url).then((res)=>{
					this.canClick = false;
					setTimeout(()=>{
						this.canClick = true;
					},500);
                    sessionStorage.setItem('orderId',res.data.id);
                    this.orderId = res.data.id
                    this.$http.post('orders/' + this.orderId + '/add', body).then((res)=>{
						// 
						try {
							let pId = `${this.nowSelSpec}_&_${productId}`;
							if(res.data.items && Array.isArray(res.data.items) && res.data.items.length){
								res.data.items.forEach(it=>{
									if((`${it.specs}_&_${it.productId}` == pId && it.matchEnabled) || (it.productId==productId && it.matchEnabled)){
										this.doShowPeiGoods(it);
									}
								})
							}
						} catch (error) {
							console.log(error);
						}
						// 
						this.fromSelSpec = false;
                        this.showSelSpec = false;
				    	// $('#animateBox').css('top', $(event.target).position().top);
						// $('#animateBox').css('left', $(event.target).position().left+30);
						$('#animateBox').css('top', $(event.target).position().top);
				    	$('#animateBox').css('left', $(event.target).position().left+30);
				    	$('#animateBox').css('display', 'block');
				    	$('#animateBox').stop().animate({
				    		top: 350,
		    				left: this.goodAnimateLeft+350
				    	}, 1500, function () {
				    		$('#animateBox').css('display', 'none');
				    	});

				        let body = res.data;
				        this.choiceArr = body.items;

				        this.goodLength = 0;
				        for (var i = 0, len = this.choiceArr.length; i < len; i++) {
				        	this.goodLength += this.choiceArr[i].quantity;
				        }
				        this.totalPrice = {
				            count: body.count, // 总数量
				            total: body.total, // 总计金额
				            discount: body.discount, // 优惠金额
				            amount: body.amount, // 最终价格
				        }
				        this.addGoodBtn = true;

				        this.$message({
				        	message: '成功',
				        	type: 'success'
				        })
				        this.customPriceBtn = false;
				        this.customPrice = '';
				    }).catch((err)=>{
						this.fromSelSpec = false;
                        this.showSelSpec = false;
				        this.addGoodBtn = true;
				        if ( err.response.status === 400 ) {
				            this.checkOrderStatus();
				        }
				    })
				})
				
                return;
		    }
		    this.$http.post('orders/' + this.orderId + '/add', body).then((res)=>{
				// 
				try {
					let pId = `${this.nowSelSpec}_&_${productId}`;
					if(res.data.items && Array.isArray(res.data.items) && res.data.items.length){
						res.data.items.forEach(it=>{
							if((`${it.specs}_&_${it.productId}` == pId && it.matchEnabled) || (it.productId==productId && it.matchEnabled)){
								this.doShowPeiGoods(it);
							}
						})
					}
				} catch (error) {
					console.log(error);
				}
				// 
				this.fromSelSpec = false;
                this.showSelSpec = false;
		    	$('#animateBox').css('top', $(event.target).position().top);
				$('#animateBox').css('left', $(event.target).position().left+30);
		    	$('#animateBox').css('display', 'block');
		    	$('#animateBox').stop().animate({
		    		top: 350,
		    		left: this.goodAnimateLeft+350
		    	}, 1500, function () {
		    		$('#animateBox').css('display', 'none');
		    	});

		        let body = res.data;
		        this.choiceArr = body.items;

		        this.goodLength = 0;
		        for (var i = 0, len = this.choiceArr.length; i < len; i++) {
		        	this.goodLength += this.choiceArr[i].quantity;
		        }
		        this.totalPrice = {
		            count: body.count, // 总数量
		            total: body.total, // 总计金额
		            discount: body.discount, // 优惠金额
		            amount: body.amount, // 最终价格
		        }
		        this.addGoodBtn = true;

		        this.$message({
		        	message: '成功',
		        	type: 'success'
		        })
		        this.customPriceBtn = false;
				this.customPrice = '';
				this.canClick = false;
				setTimeout(()=>{
					this.canClick = true;
				},500);
		    }).catch((err)=>{
				this.fromSelSpec = false;
                this.showSelSpec = false;
				this.addGoodBtn = true;
				this.canClick = false;
				setTimeout(()=>{
					this.canClick = true;
				},500);
		        if ( err.response.status === 400 ) {
		            this.checkOrderStatus();
		        }
		    })
		},
		// 减少商品
		reduceProduct: function (item, productId, quantity ) {
			if(!this.canClick){
                return;
            }
		    if ( !this.reduceGoodBtn ) {
		        return;
		    }
		    this.reduceGoodBtn = false;
		    this.$http.post('orders/' + this.orderId + '/remove', {
		        "productId": productId,
		        "productCount": quantity?quantity:1,
                specs:(item.specs&&Array.isArray(item.specs)&&item.specs.length)?item.specs:undefined
		    }).then((res)=>{
		        let body = res.data;
		    	if(body==''){
                    //订单已经删除
                    this.choiceArr = [];
		            this.showCarDetail = false;
                    this.goodLength = 0;
                    this.totalPrice = {
                        count: 0, // 总数量
                        total: 0, // 总计金额
                        discount: 0, // 优惠金额
                        amount: 0, // 最终价格
                    };
                    this.createOrder();
                    this.reduceGoodBtn = true;
                    return;
                }
		        this.choiceArr = body.items;
		        if ( this.choiceArr.length <= 0 ) {
		            this.showCarDetail = false;
		        }
		        this.goodLength = 0;
		        for (var i = 0, len = this.choiceArr.length; i < len; i++) {
		        	this.goodLength += this.choiceArr[i].quantity;
		        }
		        this.totalPrice = {
		            count: body.count, // 总数量
		            total: body.total, // 总计金额
		            discount: body.discount, // 优惠金额
		            amount: body.amount, // 最终价格
		        }
				this.reduceGoodBtn = true;
				this.canClick = false;
                setTimeout(()=>{
                    this.canClick = true;
                },500);
		    }).catch(()=>{
				this.canClick = false;
                setTimeout(()=>{
                    this.canClick = true;
                },500);
		        this.reduceGoodBtn = true;
		        if ( err.response.status === 400 ) {
		            this.checkOrderStatus();
		        }
		    })
		},
		// 判断订单状态
		checkOrderStatus: function () {
			this.$http.get('orders/' + this.orderId).then((res)=>{
			    if ( this.newOrderStatus[res.data.status] ) {
			        // setTimeout(()=>{
			        //     this.$message({
			        //         message: "已重新生成订单",
			        //         customClass: 'error'
			        //     });
			        // }, 2000)
			        this.showCarDetail = false;
			        this.createOrder();
		    		this.totalPrice.amount = 0;
			    }
			});
		},
		//关闭
		closePersonBox(){
			this.showLoding=false;
			clearTimeout(this.personTimer);
		},
		// 刷新会员信息
		refreshVipData: function ( memberId ) {
			// this.$http.get(orderId+'/member-info').then((res)=>{
			// 	this.personData = res.data;
			// 	sessionStorage.setItem('personData', JSON.stringify(this.personData));
			// });
			this.$http.get('stores/'+this.storeId+'/member-info?memberId='+memberId).then((res)=>{
				this.personData = res.data;
				this.choiceArr = res.data.order.items;
				this.totalPrice = {
					count: res.data.order.count, // 总数量
					total: res.data.order.total, // 总计金额
					discount: res.data.order.discount, // 优惠金额
					amount: res.data.order.amount, // 最终价格
				}
				sessionStorage.setItem('personData', JSON.stringify(this.personData));
			})
		},
		//轮询获取用户信息
		getMember(){
			this.$http.get(this.orderId+'/member-info').then((res)=>{
				if(res.data==''){
					this.personTimer=setTimeout(()=>{
						this.getMember();
					},2000)
				}else {
					this.showLoding = false;
					this.personData = res.data;
					this.showBalance = true;

					// 
					this.choiceArr = res.data.order.items;
					this.totalPrice = {
						count: res.data.order.count, // 总数量
						total: res.data.order.total, // 总计金额
						discount: res.data.order.discount, // 优惠金额
						amount: res.data.order.amount, // 最终价格
					}
					// 
					sessionStorage.setItem('personData', JSON.stringify(this.personData));

					this.getCouponList();
					this.getOrderCoupon();
				}
			});
		},
		// 点击登录按钮进行扫码登录
		getMemberForBtn: function () {
			this.$http.get(this.orderId+'/member-info').then((res)=>{
				if(res.data==''){
					// this.personTimer=setTimeout(()=>{
					// 	this.getMemberForBtn();
					// },2000)
				}else {
					this.showLoding = false;
					this.showBalance = false;
					this.personData = res.data;

					this.choiceArr = res.data.order.items;
					this.totalPrice = {
						count: res.data.order.count, // 总数量
						total: res.data.order.total, // 总计金额
						discount: res.data.order.discount, // 优惠金额
						amount: res.data.order.amount, // 最终价格
					}

					sessionStorage.setItem('personData', JSON.stringify(this.personData));
				}
			});
		},
		// 点击结算按钮
		goBalance: function () {
			// this.orderNotes();//备注
			if ( /[`~!@#$%^&*()_+<>?:"{},.\/;'[\]]/im.test(this.notes) ) {
				this.$message({
				    message: "备注不能含有特殊字符！",
				    type: 'error'
				});
				return;
			}
			// 
			if(this.storeInfo.deliveryEnabled){
				if(!this.nowSelEmp){
					if(this.emps && Array.isArray(this.emps) && this.emps.length){
						this.$message({
							message: '请选择配送人员！',
							type: 'error'
						})
						return;
					}
					
				}
			}
			// 

			this.showVipCheckMask = false;

			this.showLoding = false;
			// this.showBalance = true;

			let nowPersonData = JSON.parse(sessionStorage.getItem('personData'));

			if(nowPersonData&&nowPersonData.id){
				this.getCouponList();
				// this.getOrderCoupon();
			}else{
				this.couponList = [];
			}

			if(!this.totalPrice.amount || this.totalPrice.amount==0){
				this.cashierPay();
				return;
			}
			// 
			this.beforePayByAlipayOrWechat(false);
			// 


			// this.$http.get('orders/' + this.orderId).then((res)=>{
			// 	if( !res.data.memberId ) {
			// 		this.showLoding = true;
			// 		//初次登录
			// 		this.$http.get('login?storeId='+this.storeId+'&orderId='+this.orderId).then((res)=>{
			// 			setTimeout(()=>{
			// 				$('#qrcode')[0].innerHTML='';
			// 				let qrcode = new QRCode("qrcode", {
			// 	                text: res.data,
			// 	                colorDark : "#000000",
			// 	                colorLight : "#ffffff",
			// 	                height: 200,
			// 	                width: 200,
			// 	                correctLevel : QRCode.CorrectLevel.H
			// 	            });
			// 			},200)
			// 			this.personTimer = setTimeout(()=>{
			// 				this.getMemberForBtn();
			// 			},2000)
			// 		}).catch(( err )=>{

			// 		})
			// 	} else {
			// 		this.showLoding = false;
			// 		//第二次登录
			// 		this.showBalance = true;
					// this.getCouponList();
					// this.getOrderCoupon();
			// 	}
			// });
		},
		// 获取优惠券列表
		getCouponList: function () {
			this.$http.get(this.personData.id+'/coupon-instance?storeId='+this.storeId+'&page='+this.curCouponPage+'&size='+this.couponPageSize).then((res)=>{
				this.couponList = res.data.couponInstances;
			}).catch(()=>{

			})
		},
		// 获取订单信息中的优惠券
		getOrderCoupon: function () {
			this.$http.get('orders/' + this.orderId).then((res)=>{
		        let body = res.data;
		        this.curBindCoupon = {
		        	title: '无优惠'
		        };
		        if ( body.couponInstances[0] ) {
			        this.curBindCoupon = {
			        	title: body.couponInstances[0].couponName,
			        	code: body.couponInstances[0].couponInstanceCode,
			        	productName: body.couponInstances[0].productName
			        }
					this.curBindCoupon = body.couponInstances;
		        }
		    });
		},
		// 开启关闭优惠券框
		triggerCoupon: function () {
			if ( $('#couponBox').css('height') == '30px' ) {
				$('#couponBox').css('height', 150);
			} else {
				$('#couponBox').css('height', 30);
			}
		},
		// 去会员支付
		goVipPay: function () {
			// 
			this.$http.get('orders/' + this.orderId).then((res)=>{
				if( !res.data.memberId ) {
					this.showLoding = true;
					//初次登录
					this.$http.get('login?storeId='+this.storeId+'&orderId='+this.orderId).then((res)=>{
						setTimeout(()=>{
							$('#qrcode')[0].innerHTML='';
							let qrcode = new QRCode("qrcode", {
				                text: res.data,
				                colorDark : "#000000",
				                colorLight : "#ffffff",
				                height: 200,
				                width: 200,
				                correctLevel : QRCode.CorrectLevel.H
				            });
						},200)
						this.personTimer = setTimeout(()=>{
							this.getMemberForBtn();
						},2000)
					}).catch(( err )=>{

					})
				} else {
					this.showLoding = false;
					//第二次登录
					this.showBalance = true;
					this.getCouponList();
					this.getOrderCoupon();
					// 
					this.vipPay();
				}
			});
			// 
		},
		vipPay(){
			if ( !this.payBtn ) {
				return;
			}
			this.payBtn = false;

			const loading = this.$loading({
				lock: true,
				text: 'Loading',
				spinner: 'el-icon-loading',
				background: 'rgba(0, 0, 0, 0.7)'
			});

			clearInterval(this.intervalTimer);
			// 
			let deliveryParams = {};
			if(this.storeInfo.deliveryEnabled){
				if(this.nowSelEmp){
					if(this.emps && Array.isArray(this.emps) && this.emps.length){
						this.emps.forEach(it=>{
							if(it.id == this.nowSelEmp){
								deliveryParams = {
									mobile:it.mobile,
									name:it.name,
								}
							}
						})
					}
				}else{
					if(this.emps && Array.isArray(this.emps) && this.emps.length){
						this.$message({
							message: '请选择配送人员！',
							type: 'error'
						})
						return;
					}
				}
			}
			// 
			this.$http.put('pre-payment', {orderId: this.orderId,tableNo:this.tableNo,notes:this.notes,...deliveryParams}).then((res)=>{
				this.showVipPayCode = true;
				loading.close();
				setTimeout(()=>{
					$('#vipQRCode')[0].innerHTML='';
					let qrcode = new QRCode("vipQRCode", {
		                text: res.data,
		                colorDark : "#000000",
		                colorLight : "#ffffff",
		                height: 200,
		                width: 200,
		                correctLevel : QRCode.CorrectLevel.H
		            });
				},200)
				let overTimeNum = 0;
			    this.intervalTimer = setInterval(()=>{
			    	overTimeNum += 2;
			    	if ( overTimeNum >= 180 ) { // 超过180秒，取消订单
			    		this.cancelPayment();
			    	    return;
			    	}
			    	this.$http.get('orders/' + this.orderId).then((res)=>{
			    		let body = res.data;
			    		if ( body.status == 'FINISH' || body.status == 'UNFINISHED' ) {
							this.getGoods();
			    			clearInterval(this.intervalTimer);
			    			this.oldAmountPrice = this.totalPrice.amount;
			    			this.goodLength = 0;
			    			this.showCode = false;
			    			this.showVipPayCode = false;
			    			this.showCarDetail = false;
			    			this.showBalance = false;
			    			this.showPaySuccess = true;
			    			let oldOrderId = this.orderId;
			    			this.createOrder();
							this.refreshVipData( this.personData.id );
							
			    		}
			    	}).catch(()=>{
			    		clearInterval(this.intervalTimer);
			    		this.showCode = false;
			    		this.showVipPayCode = false;
						if(this.storeInfo.deliveryEnabled){
							this.showSelEmp = true;
							this.showBalance = false;
						}
			    	})
			    }, 2000)

			    this.payBtn = true;
			}).catch(()=>{
			    this.payBtn = true;
			    loading.close();
			})
		},
		beforePayByAlipayOrWechat(boo){
			if(this.storeInfo.deliveryEnabled){
				if(this.nowSelEmp){
					this.$http({
						url:`${this.baseURL}v1/pay/emp/work`,
						method:"GET",
						params:{
							empId:this.nowSelEmp
						}
					}).then(res=>{
						this.payByAlipayOrWechat(boo);
					}).catch(err=>{
						this.getEmps();
						this.showBalance = false;
						this.showSelEmp = true;
						console.log(err)
					})
				}else{
					if(!this.emps || !Array.isArray(this.emps) || !this.emps.length){
						this.payByAlipayOrWechat(boo);
						return;
					}
					if(this.emps && Array.isArray(this.emps) && this.emps.length){
						this.$message({
							message: '请选择配送人员！',
							type: 'error'
						})
						return;
					}
				}
			}else{
				this.payByAlipayOrWechat(boo);
			}
		},
		sureOnlinePay(){
			this.$http({
				url:""
			})
		},
		reGetCode(boo){
			console.log("jjj")
			if ( !this.payBtn ) {
				return;
			}
			this.payBtn = false;
			console.log("jjj")
			if(this.intervalTimer){
				clearInterval(this.intervalTimer);
			}
			let deliveryParams = {};
			if(this.storeInfo.deliveryEnabled){
				if(this.nowSelEmp){
					if(this.emps && Array.isArray(this.emps) && this.emps.length){
						this.emps.forEach(it=>{
							if(it.id == this.nowSelEmp){
								deliveryParams = {
									mobile:it.mobile,
									name:it.name,
								}
							}
						})
					}
				}else{
					if(this.emps && Array.isArray(this.emps) && this.emps.length){
						this.$message({
							message: '请选择配送人员！',
							type: 'error'
						})
						this.payBtn = true;
						return;
					}
					
				}
			}
			this.$http.post(API_BASE_URL+'v1/pay/scan-code', {
				"orderId": this.orderId,
				"type": boo,
				"tableNo": this.tableNo,
				"notes": this.notes,
                "coupon":this.curSelCouponId,
				...deliveryParams
			}).then((res)=>{
			    this.payBtn = true;
				this.nowType = res.data.channel;
			    this.showCode = true;
				this.payImgUrl = "";
				this.payImgUrl = res.data.url;
				// 
				this.showBalance = true;
				// 
				if(res.data.channel != 'HUI_SHANG'){
					// 
					setTimeout(()=>{
						$('#payQrCode')[0].innerHTML='';
						let qrcode = new QRCode("payQrCode", {
							text: res.data.url,
							colorDark : "#000000",
							colorLight : "#ffffff",
							height: 200,
							width: 200,
							correctLevel : QRCode.CorrectLevel.H
						});
					},200);
					// 
				}
			    this.payMode = res.data.payMode;
			    //如果是支付宝、微信收款码收账，不再轮询
			    if(res.data.payMode=='CASHIER'){
			    	this.payBtn = true;
			    	if(boo){
			    		this.cashierPayType = "ALIPAY_CASH"
			    	}else{
			    		this.cashierPayType = "WECHATPAY_CASH"
			    	}
			    	return;
			    }
				return;
			    let overTimeNum = 0;
			    this.intervalTimer = setInterval(()=>{
			    	overTimeNum += 2;
			    	if ( overTimeNum >= 180 ) { // 超过180秒，取消订单
			    		this.cancelPayment();
			    	    return;
			    	}
			        this.$http.get(API_BASE_URL+'v1/pay/scan-code/query?orderId='+this.orderId).then((res)=>{
			            if ( res.status === 200 ) {
							this.getGoods();
			                clearInterval(this.intervalTimer);
			                this.oldAmountPrice = this.totalPrice.amount;
			                this.goodLength = 0;
			                this.showCode = false;
			                this.showCarDetail = false;
			                this.showBalance = false;
			                this.showPaySuccess = true;
			                let oldOrderId = this.orderId;
			                this.createOrder();
							this.refreshVipData( this.personData.id );
			            }
			        }).catch(()=>{
			        	clearInterval(this.intervalTimer);
			        	this.showCode = false;
			        })
			    }, 2000)
			    this.payBtn = true;
			}).catch(()=>{
			    this.payBtn = true;
				if(this.storeInfo.deliveryEnabled){
					this.showSelEmp = true;
					this.showBalance = false;
				}
				this.delOrder();
			})
		},
		// 通过支付宝或微信支付，true为支付宝，false为微信
		payByAlipayOrWechat: function ( boo ) {
			if ( !this.payBtn ) {
				return;
			}
			this.payBtn = false;

			const loading = this.$loading({
				lock: true,
				text: 'Loading',
				spinner: 'el-icon-loading',
				background: 'rgba(0, 0, 0, 0.7)'
			});
			clearInterval(this.intervalTimer);
			let deliveryParams = {};
			if(this.storeInfo.deliveryEnabled){
				if(this.nowSelEmp){
					if(this.emps && Array.isArray(this.emps) && this.emps.length){
						this.emps.forEach(it=>{
							if(it.id == this.nowSelEmp){
								deliveryParams = {
									mobile:it.mobile,
									name:it.name,
								}
							}
						})
					}
				}else{
					// this.$message({
					// 	message: '请选择配送人员！',
					// 	type: 'error'
					// })
					// this.payBtn = true;
					// loading.close();
					// return;
				}
			}
			console.log("curSelCouponId",this.curSelCouponId)
			this.$http.post(API_BASE_URL+'v1/pay/scan-code', {
				"orderId": this.orderId,
				"type": boo,
				"tableNo": this.tableNo,
				"notes": this.notes,
                "coupon":this.curSelCouponId,
				...deliveryParams
			}).then((res)=>{
				loading.close();
				this.nowType = res.data.channel;
			    this.showCode = true;
				this.payImgUrl = res.data.url;
				// 
				this.showBalance = true;
				// 
				if(res.data.channel != 'HUI_SHANG'){
					// 
					setTimeout(()=>{
						$('#payQrCode')[0].innerHTML='';
						let qrcode = new QRCode("payQrCode", {
							text: res.data.url,
							colorDark : "#000000",
							colorLight : "#ffffff",
							height: 200,
							width: 200,
							correctLevel : QRCode.CorrectLevel.H
						});
					},200);
					// 
				}
			    this.payMode = res.data.payMode;
			    //如果是支付宝、微信收款码收账，不再轮询
			    if(res.data.payMode=='CASHIER'){
			    	this.payBtn = true;
			    	if(boo){
			    		this.cashierPayType = "ALIPAY_CASH"
			    	}else{
			    		this.cashierPayType = "WECHATPAY_CASH"
			    	}
			    	return;
			    }
				// 
				this.connect(this.orderId);
				// 
			    // let overTimeNum = 0;
			    // this.intervalTimer = setInterval(()=>{
			    // 	overTimeNum += 2;
			    // 	if ( overTimeNum >= 180 ) { // 超过180秒，取消订单
			    // 		this.cancelPayment();
			    // 	    return;
			    // 	}
			    //     this.$http.get(API_BASE_URL+'v1/pay/scan-code/query?orderId='+this.orderId).then((res)=>{
			    //         if ( res.status === 200 ) {
				// 			this.getGoods();
			    //             clearInterval(this.intervalTimer);
			    //             this.oldAmountPrice = this.totalPrice.amount;
			    //             this.goodLength = 0;
			    //             this.showCode = false;
			    //             this.showCarDetail = false;
			    //             this.showBalance = false;
			    //             this.showPaySuccess = true;
			    //             let oldOrderId = this.orderId;
			    //             this.createOrder();
				// 			this.refreshVipData( this.personData.id );
			    //         }
			    //     }).catch(()=>{
			    //     	clearInterval(this.intervalTimer);
			    //     	this.showCode = false;
			    //     })
			    // }, 2000)
			    this.payBtn = true;
			}).catch(()=>{
				console.log("撤销订单");
			    this.payBtn = true;
				if(this.storeInfo.deliveryEnabled){
					this.showSelEmp = true;
					this.showBalance = false;
				}
				loading.close();
				this.delOrder();
			})
		},
		// 撤销订单
        delOrder: function () {
            this.$http.delete('orders/'+this.orderId).then((res)=>{
                
                this.orderId = '';
                this.curBindCoupon = []; // 清空选择的优惠券
                this.curSelCouponId = [];
                sessionStorage.removeItem("personData");
                sessionStorage.removeItem("orderId");
                // 传入index生成新订单
                this.showConfirmMask = false;
                // this.clearOrder();
                this.getGoods();
                // 
                sessionStorage.removeItem("nowCurBindCoupon");
				// 
	            this.refreshPage();
            });
        },
		// 关闭支付二维码
		closeCode: function () {
			this.showCode = false;
		},
		refreshPage(){
			setTimeout(()=>{
      			window.location.reload(true);
			},3500)
		},
		// 取消支付
		cancelPayment: function () {
			if ( !this.cancelPaymentApi ) {
				return;
			}
			this.cancelPaymentApi = false;

			clearInterval(this.intervalTimer);
			this.showCode = false;
			this.showVipPayCode = false;
			this.showDelConfirm = false;
			this.cancelPaymentApi = true;
			console.log("cancel ok");
			setTimeout(()=>{
				this.reCreateOrder();
			},3000);
			return;
			this.$http.delete('payments/'+this.orderId,{data:{source:'PC'}}).then((res)=>{
				this.$message({
					message: '支付已取消'
				})
			    this.showCode = false;
			    this.showVipPayCode = false;
			    this.showDelConfirm = false;
			    this.cancelPaymentApi = true;
			}).catch(( err )=>{
			    this.cancelPaymentApi = true;
			})
		},

		orderInfoFn(){
			if ( this.personData ) {
				this.showOfficialAccountsCode = false;
				this.showOrderDetail = true;
				this.$http.get(this.personData.id+'/orders?page='+this.orderPage+'&size='+this.orderSize).then((res)=>{
					this.orderList = res.data;
				}).catch(( err )=>{

				})

			} else {
				this.showLoding = true;
				//初次登录
				this.$http.get('login?storeId='+this.storeId+'&orderId='+this.orderId).then((res)=>{
					setTimeout(()=>{
						$('#qrcode')[0].innerHTML='';
						let qrcode = new QRCode("qrcode", {
			                text: res.data,
			                colorDark : "#000000",
			                colorLight : "#ffffff",
			                height: 200,
			                width: 200,
			                correctLevel : QRCode.CorrectLevel.H
			            });
					},200)
					this.personTimer=setTimeout(()=>{
						this.getMemberForBtn();
					},3000)
				}).catch(( err )=>{

				})
			}
		},

		// 退出登录
		loginOut: function () {
			this.personData = '';
			sessionStorage.clear();
			this.createOrder();
			this.$message({
				message: '成功退出',
				type: 'success'
			})
			setTimeout(()=>{
      			window.location.reload(true);
			},300)
		},
		//如果session里有订单，先获取session里的，同时要在页面上把已经选择的商品的相应商品数量显示出来，请求两个接口，给所有商品添加一个nowSelectCount字段
		getSessionOrder(){
			this.$http.get('products?storeId='+this.storeId).then((resForProducts)=>{
					// this.goodsData = resForProducts.data;
					this.orderId = sessionStorage.getItem('orderId');
					this.$http.get('orders/' + this.orderId).then((res)=>{
						let body = res.data;
						// console.log(body);
						
						for(let i=0;i<this.goodsData.length;i++){
						// if(this.goodsData[i].products !== []){
							for(let j=0;j<this.goodsData[i].products.length;j++){
								Object.assign(this.goodsData[i].products[j],{nowSelectCount:0});
								for(let x=0;x<body.items.length;x++){
									if(this.goodsData[i].products[j].id == body.items[x].productId){
										Object.assign(this.goodsData[i].products[j],{nowSelectCount:body.items[x].quantity});
									}
								}
							}
						// }
						}

						this.choiceArr = body.items;
						if ( body.couponInstances[0] ) {
							this.curBindCoupon = {
								title: body.couponInstances[0].couponName,
								code: body.couponInstances[0].couponInstanceCode,
								productName: body.couponInstances[0].productName
							}
                			this.curBindCoupon = body.couponInstances;
						}
						this.totalPrice = {
							count: body.count, // 总数量
							total: body.total, // 总计金额
							discount: body.discount, // 优惠金额
							amount: body.amount, // 最终价格
						}
						for (var i = 0, len = this.choiceArr.length; i < len; i++) {
							this.goodLength += this.choiceArr[i].quantity;
						}
						// 
						// this.$http({
						// 	url:"return-order",
						// 	method:"POST",
						// 	data:{
						// 		orderId:this.orderId
						// 	}
						// }).then(res=>{
						// 	console.log(res);
						// 	if(res.data.result.code == 200){
						// 		let body = res.data.data;

						// 		let items = body.items;
						// 		let discountOrderItem = res.data.discountOrderItem;
										
						// 		for(let i=0;i<items.length;i++){
						// 			items[i].isDiscountForSecond = false;
						// 			for(let j=0;j<discountOrderItem.length;j++){
						// 				if(items[i].id == discountOrderItem[j].orderItem.id){
						// 					items[i].discountForSecondQty = discountOrderItem[j].qty;
						// 					items[i].isDiscountForSecond = true;
						// 				}
						// 			}
						// 		}

						// 		this.choiceArr = items;

						// 		this.totalPrice = {
						// 			count:    body.count, // 总数量
						// 			total:    body.total, // 总计金额
						// 			discount: body.discount, // 优惠金额
						// 			amount:   body.amount, // 最终价格
						// 			removeZero:   body.removeZero, // 最终价格
						// 		}
						// 	}else if(res.data.result.code == 400){
						// 		this.clearOrder();
						// 	}
						// });
						// let nowCurBindCoupon = JSON.parse(sessionStorage.getItem('nowCurBindCoupon'));
						// if(nowCurBindCoupon.length){
						// 	this.curBindCoupon = [];
						// 	this.relieveCoupon(nowCurBindCoupon);
						// }
						// 
					});
					//
				})
		},
		arraySort (array) {
			for (let i = array.length - 1; i >= 0; i--) {
				let randomIndex = Math.floor(Math.random() * (i + 1));
				let itemAtIndex = array[randomIndex];
				array[randomIndex] = array[i];
				array[i] = itemAtIndex;
			}
			return array;
		},
		getEmps(boo){
			this.$http.get('/get/delivery?storeId='+this.storeId).then((res)=>{
				// res.data.sort(function () {
				// 	return Math.random() - 0.5
				// })
				if(res.data && Array.isArray(res.data)){
					this.emps = this.arraySort(res.data);
				}
				if(boo){
					if(!res.data || !Array.isArray(res.data) || !res.data.length){
						this.goBalance();
						return;
					}
					this.showSelEmp=true;
				}
				if(res.data && Array.isArray(res.data) && res.data.length){
					// let randomCount = Math.floor(
					// 	Math.random() * res.data.length
					// );
					// this.nowSelEmp = res.data[randomCount].id;
				}
			})
		},
		spanTime(start,end){
			if(start && end){
				let spanTime = new Date(end).getTime() - new Date(start).getTime();
				let hour = 60 * 1000 * 60;
				let min = 60 * 1000;
				let sec = 1000;
				let hours = Math.floor(spanTime / hour);
				let mins = Math.ceil((spanTime % hour) / min);
				if (hours < 0) {
					return `0小时0分`;
				}
				return `${hours}小时${mins}分`;
			}else{
				return "-"
			}
		},
		handleCloseForRentInfo(e){
			this.showMyRentInfo = false;
			if(this.rentTimer){
				clearInterval(this.rentTimer);
			}
		},
		doShowMyRentInfo(){
			this.showMyRentInfo = true;
			try {
				if(this.rentForm && this.rentForm.numId){
					this.rentTimer = setInterval(()=>{
						this.getMyRentInfo(this.rentForm.numId);
					},1000);
				}
			} catch (error) {
				console.log("error",error)
			}
		},
		getMyRentInfo(numId){
			this.$http({
				url:`${API_BASE_URL}v1/call/order/by/id`,
				method:"POST",
				data:{
					numId,
                    storeId:this.storeId
				}
			}).then(res=>{
				if(res.data && Array.isArray(res.data) && res.data.length){
					this.myRentData = res.data;
				}else{
					this.myRentData = [];
				}
				this.$forceUpdate();
			})
		},
		getRegionList(){
			let tableNo = decodeURI(this.tableNo);
			try {
				tableNo = tableNo.replace(/\D/g, '');
			} catch (error) {
				console.log("error",error);
			}
			console.log("KKKKKK,tableNo",tableNo)
            this.$http({
                url:"region/list",
                method:"POST",
                data:{
                    storeId:this.storeId
                }
            }).then(res=>{
                if(res.data && Array.isArray(res.data) && res.data.length){
                    this.areas = res.data;
					res.data.forEach(it=>{
						if(it.nums && Array.isArray(it.nums) && it.nums.length){
							it.nums.forEach(ite=>{
								if(Number(tableNo) == Number(ite.name)){
									this.rentForm.numId = ite.id;
                        			this.rentForm.numName = ite.name;
									this.getMyRentInfo(ite.id);
								}
							})
						}
						
					})
					
                }
            })
        }
	},
	
	 created: function () {
		this.getEmps();
		this.getGoods();
		this.$http.get('/store?storeId='+this.storeId).then((res)=>{
			this.storeInfo = res.data;
			this.leaseProductEnabled = res.data.leaseProductEnabled;
			this.memberEnabled = res.data.memberEnabled;

		})
		// 判断是否有缓存订单
		if ( sessionStorage.getItem('orderId') ) {
			//
				this.orderId = sessionStorage.getItem('orderId');
				this.getSessionOrder();
				this.returnOrderStatus(this.orderId);
			//
		} else {
		    // 生成订单
		    // this.createOrder();
		}
	    this.personData = JSON.parse(sessionStorage.getItem('personData'));
	    if ( this.personData && this.personData.id ) {
	    	this.refreshVipData(this.personData.id);
	    }
	},
	mounted: function () {
		try {
			setTimeout(()=>{
				this.getRegionList();
			},1000);
        } catch (error) {
            console.log(error);
        }
		$(document).ready(()=>{
			this.goodAnimateLeft = $(window).width() - 410;
		})
	},
	beforeDestroy: function () {

	}
}
</script>
<style lang="scss" scoped>
	@import "home";
	.emp-wrap{
		width: 100%;
		max-height: 425px;
		overflow: hidden;
		overflow-y: auto;
		.emp-item{
			display: inline-block;
			width: 25%;
			padding: 0 10px;
			padding-bottom: 45px;
			box-sizing: border-box;
			.item-inner-wrap{
				width: 100%;
				text-align: center;
				.item-avatar{
					width: 100%;
					height: 100px;
					img{
						width: 100px;
						height: 100px;
						border-radius: 50px;
						background-color: #ccc;
						cursor: pointer;
						object-fit: cover;
					}
				}
				.item-name{
					font-size: 18px;
					font-weight: bold;
					padding: 10px 0;
					width: 150px;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
				.btn{
					display: inline-block;
					font-size: 16px;
					font-weight: 400;
					background-color: #fd8d20;
					color: #fff;
					width: 100px;
					height:36px;
					line-height: 35px;
					border-radius: 18px;
					user-select: none;
					cursor: pointer;
				}
			}
		}
	}
	
</style>
<style lang="scss">
	.el-input{
		input{
			border-color:#fd8d20;
		}
	}
	.coupon-scroll-box{
		.el-dropdown{
		  width: 100%;
		  min-height: 68px;
		}
	}
	.rent-wrap{
		.tit{
			font-size:18px;
			font-weight:bold;
			text-align:center;
		}
		.sel-item-wrap{
			padding:20px 0;
		}
		.rent-list{
			.rent-head{
				width:100%;
				height:40px;
				background:#059313;
				color:#fff;
				display:flex;
				align-items:center;
				.it{
					display:inline-block;
					text-align:center;
					width:50%;
				}
			}
			.rent-goods{
				background:#f4f4f4;
				.r-li{
					min-height:40px;
					width:100%;
					display:flex;
					flex-wrap:wrap;
					align-items:center;
					.it{
						width:50%;
						display:inline-block;
						text-align:center;
					}
				}
			}
		}
		.btns{
			padding:20px 0;
			.btn{
				width:100%;
				border-radius:5px;
				display:inline-block;
				text-align:center;
				line-height:40px;
				height:40px;
				background:#e66a6a;
				color:#fff;
				cursor:pointer;
			}
		}
	}
	.sel-item-wrap{
        .sel-item{
            .item-name{
                width:100%;
                font-weight:bold;
                font-size:16px;
                padding:10px 0;
            }
            .sel-cont{
                width:100%;
                display:flex;
                align-items:center;
                justify-content:space-between;
                flex-wrap:wrap;
                white-space:nowrap;
                .cont-item{
                    width:100%;
                    padding-bottom:15px;
                    .cont-name{
                        display:inline-block;
                        width:50px;
                    }
                }
            }
        }
		.el-input{
			input{
				border-color:#ccc;
			}
		}
    }
	.order-loading{
		position: fixed;
		top:0;
		left:0;
		right:0;
		bottom:0;
		background-color: rgba(0,0,0,.789);
		z-index: 999;
		.wrap{
			width: 350px;
			padding: 30px;
			padding-top: 40px;
			background-color: #fff;
			border-radius: 10px;
			color: #333;
			position: absolute;
			top: 50%;
			left:50%;
			transform: translate(-50%,-50%);
			text-align: center;
			font-size: 20px;
			line-height: 30px;
			.time-count{
				color: red;
			}
			.btn{
				.re{
					font-size: 16px;
					display: inline-block;
					padding: 10px 20px;
					color: #fff;
					background-color: #ccc;
					cursor: pointer;
					border-radius: 5px;
					margin-top: 50px;
					&.active{
						background-color: #fd8d20;
					}
				}				
			}
		}
	}
	.rentTime{
		font-weight:bold;
	}
	.rentPrice{
		color:#fd8d20;
		font-weight:bold;
	}
	.statusTag{
		display: inline-block;
		padding:3px 10px;
		background-color: rgb(5, 192, 21);
		border-radius: 5px;
		color:#fff;
		&.refund{
			background-color: #999;
		}
	}
	.myRentBtn{
		display:flex;
		align-items:center;
		flex-wrap: nowrap;
		white-space: nowrap;
		margin-right:30px;
		cursor:pointer;
		b{
			padding-left: 5px;
		}
	}
</style>